From: Jonathan Cameron <jic23@kernel.org>
To: Charles Han <hanchunchao@inspur.com>
Cc: <marius.cristea@microchip.com>, <dlechner@baylibre.com>,
<nuno.sa@analog.com>, <andy@kernel.org>,
<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: adc: Fix a null pointer dereference in pac1934_acpi_parse_channel_config
Date: Mon, 1 Sep 2025 17:49:19 +0100 [thread overview]
Message-ID: <20250901174919.4e2c7873@jic23-huawei> (raw)
In-Reply-To: <20250901064512.1554-1-hanchunchao@inspur.com>
On Mon, 1 Sep 2025 14:45:11 +0800
Charles Han <hanchunchao@inspur.com> wrote:
> Add check for the return value of devm_kmemdup()
> to prevent potential null pointer dereference.
>
> Fixes: 0fb528c8255b ("iio: adc: adding support for PAC193x")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
Good catch, but not that simple. This just leaked an ACPI resource that was
held over the loop this is in. See the ACPI_FREE() that follows it.
Jonathan
> ---
> drivers/iio/adc/pac1934.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/adc/pac1934.c b/drivers/iio/adc/pac1934.c
> index 2e442e46f679..95c9d14b5529 100644
> --- a/drivers/iio/adc/pac1934.c
> +++ b/drivers/iio/adc/pac1934.c
> @@ -1108,6 +1108,9 @@ static int pac1934_acpi_parse_channel_config(struct i2c_client *client,
> devm_kmemdup(dev, rez->package.elements[i].string.pointer,
> (size_t)rez->package.elements[i].string.length + 1,
> GFP_KERNEL);
> + if (!info->labels[idx])
> + return -ENOMEM;
> +
> info->labels[idx][rez->package.elements[i].string.length] = '\0';
> info->shunts[idx] = rez->package.elements[i + 1].integer.value * 1000;
> info->active_channels[idx] = (info->shunts[idx] != 0);
next prev parent reply other threads:[~2025-09-01 16:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 6:45 Charles Han
2025-09-01 16:49 ` Jonathan Cameron [this message]
2025-09-01 16:49 ` David Lechner
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=20250901174919.4e2c7873@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=hanchunchao@inspur.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marius.cristea@microchip.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 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®