[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241118090208.14586-1-hanchunchao@inspur.com>
Date: Mon, 18 Nov 2024 17:02:08 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <mike.looijmans@...ic.nl>, <jic23@...nel.org>, <lars@...afoo.de>,
<dan.carpenter@...aro.org>, <nuno.sa@...log.com>,
<andriy.shevchenko@...ux.intel.com>, <viro@...iv.linux.org.uk>,
<yujiaoliang@...o.com>
CC: <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Charles Han
<hanchunchao@...pur.com>
Subject: [PATCH] iio: adc: ti-ads1298: Add NULL check in ads1298_init
devm_kasprintf() can return a NULL pointer on failure,but this
returned value in ads1298_init() is not checked.
Add NULL check in ads1298_init(), to handle kernel NULL
pointer dereference error.
Fixes: 00ef7708fa60 ("iio: adc: ti-ads1298: Add driver")
Signed-off-by: Charles Han <hanchunchao@...pur.com>
---
drivers/iio/adc/ti-ads1298.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/adc/ti-ads1298.c b/drivers/iio/adc/ti-ads1298.c
index 36d43495f603..03f762415fa5 100644
--- a/drivers/iio/adc/ti-ads1298.c
+++ b/drivers/iio/adc/ti-ads1298.c
@@ -613,6 +613,8 @@ static int ads1298_init(struct iio_dev *indio_dev)
}
indio_dev->name = devm_kasprintf(dev, GFP_KERNEL, "ads129%u%s",
indio_dev->num_channels, suffix);
+ if (!indio_dev->name)
+ return -ENOMEM;
/* Enable internal test signal, double amplitude, double frequency */
ret = regmap_write(priv->regmap, ADS1298_REG_CONFIG2,
--
2.31.1
Powered by blists - more mailing lists