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

Configure Feed

Select the types of activity you want to include in your feed.

iio: light: al3010: Fix an error handling path in al3010_probe()

If i2c_smbus_write_byte_data() fails in al3010_init(),
al3010_set_pwr(false) is not called.

In order to avoid such a situation, move the devm_add_action_or_reset()
witch calls al3010_set_pwr(false) right after a successful
al3010_set_pwr(true).

Fixes: c36b5195ab70 ("iio: light: add Dyna-Image AL3010 driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/ee5d10a2dd2b70f29772d5df33774d3974a80f30.1725993353.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Christophe JAILLET and committed by
Jonathan Cameron
a4b7064d 762186c6

+5 -6
+5 -6
drivers/iio/light/al3010.c
··· 87 87 int ret; 88 88 89 89 ret = al3010_set_pwr(data->client, true); 90 + if (ret < 0) 91 + return ret; 90 92 93 + ret = devm_add_action_or_reset(&data->client->dev, 94 + al3010_set_pwr_off, 95 + data); 91 96 if (ret < 0) 92 97 return ret; 93 98 ··· 194 189 dev_err(&client->dev, "al3010 chip init failed\n"); 195 190 return ret; 196 191 } 197 - 198 - ret = devm_add_action_or_reset(&client->dev, 199 - al3010_set_pwr_off, 200 - data); 201 - if (ret < 0) 202 - return ret; 203 192 204 193 return devm_iio_device_register(&client->dev, indio_dev); 205 194 }