mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: adc: Fix a null pointer dereference in pac1934_acpi_parse_channel_config
@ 2025-09-01  6:45 Charles Han
  2025-09-01 16:49 ` Jonathan Cameron
  2025-09-01 16:49 ` David Lechner
  0 siblings, 2 replies; 3+ messages in thread
From: Charles Han @ 2025-09-01  6:45 UTC (permalink / raw)
  To: marius.cristea, jic23, dlechner, nuno.sa, andy
  Cc: linux-iio, linux-kernel, Charles Han

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>
---
 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);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-01 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-01  6:45 [PATCH] iio: adc: Fix a null pointer dereference in pac1934_acpi_parse_channel_config Charles Han
2025-09-01 16:49 ` Jonathan Cameron
2025-09-01 16:49 ` David Lechner

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®