[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250901174919.4e2c7873@jic23-huawei>
Date: Mon, 1 Sep 2025 17:49:19 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Charles Han <hanchunchao@...pur.com>
Cc: <marius.cristea@...rochip.com>, <dlechner@...libre.com>,
<nuno.sa@...log.com>, <andy@...nel.org>, <linux-iio@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] iio: adc: Fix a null pointer dereference in
pac1934_acpi_parse_channel_config
On Mon, 1 Sep 2025 14:45:11 +0800
Charles Han <hanchunchao@...pur.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@...pur.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);
Powered by blists - more mailing lists