Skip to content

Commit

Permalink
leds: tlc591xx: fix return value check in tlc591xx_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit ee522bc ]

After device_get_match_data(), tlc591xx is not checked, add
check for it and also check np after dev_of_node.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yang Yingliang authored and gregkh committed Jul 20, 2021
1 parent 9ebcc60 commit 164a388
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/leds/leds-tlc591xx.c
Expand Up @@ -148,16 +148,20 @@ static int
tlc591xx_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device_node *np = dev_of_node(&client->dev), *child;
struct device_node *np, *child;
struct device *dev = &client->dev;
const struct tlc591xx *tlc591xx;
struct tlc591xx_priv *priv;
int err, count, reg;

tlc591xx = device_get_match_data(dev);
np = dev_of_node(dev);
if (!np)
return -ENODEV;

tlc591xx = device_get_match_data(dev);
if (!tlc591xx)
return -ENODEV;

count = of_get_available_child_count(np);
if (!count || count > tlc591xx->max_leds)
return -EINVAL;
Expand Down

0 comments on commit 164a388

Please sign in to comment.