]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: light: al3010: Fix an error handling path in al3010_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Tue, 10 Sep 2024 18:36:06 +0000 (20:36 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 30 Sep 2024 08:21:03 +0000 (09:21 +0100)
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>
drivers/iio/light/al3010.c

index 53569587ccb7ba4a6bf0806d21b0fdeb43421d16..7cbb8b203300907a88f4a0ab87da89cabdd087f3 100644 (file)
@@ -87,7 +87,12 @@ static int al3010_init(struct al3010_data *data)
        int ret;
 
        ret = al3010_set_pwr(data->client, true);
+       if (ret < 0)
+               return ret;
 
+       ret = devm_add_action_or_reset(&data->client->dev,
+                                      al3010_set_pwr_off,
+                                      data);
        if (ret < 0)
                return ret;
 
@@ -190,12 +195,6 @@ static int al3010_probe(struct i2c_client *client)
                return ret;
        }
 
-       ret = devm_add_action_or_reset(&client->dev,
-                                       al3010_set_pwr_off,
-                                       data);
-       if (ret < 0)
-               return ret;
-
        return devm_iio_device_register(&client->dev, indio_dev);
 }