From: Jonathan Cameron <jic23@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
David Heidelberg <david@ixit.cz>,
Dmitry Osipenko <digetx@gmail.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: light: al3010: Fix an error handling path in al3010_probe()
Date: Sat, 14 Sep 2024 15:15:32 +0100 [thread overview]
Message-ID: <20240914151532.1c9580e2@jic23-huawei> (raw)
In-Reply-To: <ee5d10a2dd2b70f29772d5df33774d3974a80f30.1725993353.git.christophe.jaillet@wanadoo.fr>
On Tue, 10 Sep 2024 20:36:06 +0200
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> 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>
Looks correct to me, but given the upshot of the bug is that in
a case where an bus access fails we don't power down (which requires a bus
access). It's unlikely to happen in practice and outcome is device
remains powered up when it shouldn't be which isn't too bad an outcome.
Hence I'll queue this up the slow way.
Applied to the testing branch of iio.git for 0-day to play with it before
I rebase on rc1 once available.
Thanks,
Jonathan
> ---
> Compile tested only.
> This patch is speculative, review with care
> ---
> drivers/iio/light/al3010.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/light/al3010.c b/drivers/iio/light/al3010.c
> index 53569587ccb7..7cbb8b203300 100644
> --- a/drivers/iio/light/al3010.c
> +++ b/drivers/iio/light/al3010.c
> @@ -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);
> }
>
prev parent reply other threads:[~2024-09-14 14:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 18:36 Christophe JAILLET
2024-09-14 14:15 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240914151532.1c9580e2@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=david@ixit.cz \
--cc=digetx@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®