From: "Nuno Sá" <noname.nuno@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
Esteban Blanc <eblanc@baylibre.com>
Cc: "Michael Hennerich" <michael.hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Jonathan Cameron" <jic23@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next] iio: adc: ad4030: fix error pointer dereference in probe()
Date: Fri, 28 Feb 2025 13:22:37 +0000 [thread overview]
Message-ID: <3c9bfa8bd08d835e0151fb66fce443457e2f2a98.camel@gmail.com> (raw)
In-Reply-To: <cc67cee7-9c65-46d2-aae3-f860fc3cc461@stanley.mountain>
On Fri, 2025-02-28 at 12:35 +0300, Dan Carpenter wrote:
> The intention here was obviously to return an error if devm_regmap_init()
> fails, but the return statement was accidentally left out. This leads to
> an error pointer dereference when we call:
>
> ret = ad4030_detect_chip_info(st);
>
> Add the return statement.
>
> Fixes: ec25cf6f1ee3 ("iio: adc: ad4030: add support for ad4632-16 and ad4632-
> 24")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> There is a second Smatch warning which we may want to fix as well:
>
> drivers/iio/adc/ad4030.c:397 ad4030_get_chan_scale()
> error: 'scan_type' dereferencing possible ERR_PTR()
>
> There's not error checking on iio_get_current_scan_type().
>
> drivers/iio/adc/ad4030.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
> index ab5497c8ea1e..b7caf7e89710 100644
> --- a/drivers/iio/adc/ad4030.c
> +++ b/drivers/iio/adc/ad4030.c
> @@ -1014,8 +1014,8 @@ static int ad4030_probe(struct spi_device *spi)
> st->regmap = devm_regmap_init(dev, &ad4030_regmap_bus, st,
> &ad4030_regmap_config);
> if (IS_ERR(st->regmap))
> - dev_err_probe(dev, PTR_ERR(st->regmap),
> - "Failed to initialize regmap\n");
> + return dev_err_probe(dev, PTR_ERR(st->regmap),
> + "Failed to initialize regmap\n");
>
> st->chip = spi_get_device_match_data(spi);
> if (!st->chip)
next prev parent reply other threads:[~2025-02-28 13:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 9:35 [PATCH next] iio: adc: ad4030: fix error pointer dereference in probe() Dan Carpenter
2025-02-28 13:22 ` Nuno Sá [this message]
2025-03-04 14:53 ` Jonathan Cameron
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=3c9bfa8bd08d835e0151fb66fce443457e2f2a98.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=eblanc@baylibre.com \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=nuno.sa@analog.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.