Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: tlc591xx: fix return value check in tlc591xx_probe()

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>

authored by

Yang Yingliang and committed by
Pavel Machek
ee522bcf 6efb943b

+6 -2
+6 -2
drivers/leds/leds-tlc591xx.c
··· 148 148 tlc591xx_probe(struct i2c_client *client, 149 149 const struct i2c_device_id *id) 150 150 { 151 - struct device_node *np = dev_of_node(&client->dev), *child; 151 + struct device_node *np, *child; 152 152 struct device *dev = &client->dev; 153 153 const struct tlc591xx *tlc591xx; 154 154 struct tlc591xx_priv *priv; 155 155 int err, count, reg; 156 156 157 - tlc591xx = device_get_match_data(dev); 157 + np = dev_of_node(dev); 158 158 if (!np) 159 + return -ENODEV; 160 + 161 + tlc591xx = device_get_match_data(dev); 162 + if (!tlc591xx) 159 163 return -ENODEV; 160 164 161 165 count = of_get_available_child_count(np);