From: Jonathan Cameron <jic23@kernel.org>
To: Zheyu Ma <zheyuma97@gmail.com>
Cc: lars@metafoo.de, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] iio: magnetometer: ak8974: Fix the error handling of ak8974_probe()
Date: Sun, 10 Apr 2022 16:54:25 +0100 [thread overview]
Message-ID: <20220410165425.6c2f60e7@jic23-huawei> (raw)
In-Reply-To: <20220409034849.3717231-1-zheyuma97@gmail.com>
On Sat, 9 Apr 2022 11:48:48 +0800
Zheyu Ma <zheyuma97@gmail.com> wrote:
> When the driver fail at devm_regmap_init_i2c(), we will get the
> following splat:
>
> [ 106.797388] WARNING: CPU: 4 PID: 413 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> [ 106.802183] RIP: 0010:_regulator_put+0x3ec/0x4e0
> [ 106.811237] Call Trace:
> [ 106.811515] <TASK>
> [ 106.811695] regulator_bulk_free+0x82/0xe0
> [ 106.812032] devres_release_group+0x319/0x3d0
> [ 106.812425] i2c_device_probe+0x766/0x940
>
> Fix this by disabling the regulators at the error path.
>
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
+ CC Linus W as it's his driver.
Fix looks correct to me, though the handling of runtime pm in here is
probably more complex than it needs to be (and hence this odd error
handling for this one place in the probe).
Jonathan
> ---
> drivers/iio/magnetometer/ak8974.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
> index e54feacfb980..84bbf7ccc887 100644
> --- a/drivers/iio/magnetometer/ak8974.c
> +++ b/drivers/iio/magnetometer/ak8974.c
> @@ -862,6 +862,7 @@ static int ak8974_probe(struct i2c_client *i2c,
> dev_err(&i2c->dev, "failed to allocate register map\n");
> pm_runtime_put_noidle(&i2c->dev);
> pm_runtime_disable(&i2c->dev);
> + regulator_bulk_disable(ARRAY_SIZE(ak8974->regs), ak8974->regs);
> return PTR_ERR(ak8974->map);
> }
>
next prev parent reply other threads:[~2022-04-10 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-09 3:48 [PATCH] iio: magnetometer: ak8974: Fix the error handling of ak8974_probe() Zheyu Ma
2022-04-09 3:48 ` [PATCH] iio: magnetometer: ak8975: Fix the error handling in ak8975_power_on() Zheyu Ma
2022-04-10 16:01 ` Jonathan Cameron
2022-04-11 5:57 ` Zheyu Ma
2022-04-10 15:54 ` Jonathan Cameron [this message]
2022-04-20 23:14 ` [PATCH] iio: magnetometer: ak8974: Fix the error handling of ak8974_probe() Linus Walleij
2022-04-21 14:07 ` Ulf Hansson
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=20220410165425.6c2f60e7@jic23-huawei \
--to=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zheyuma97@gmail.com \
/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