diff mbox series

[v2,2/4] iio: light: isl29018: Assing ddata to NULL

Message ID 20241101081203.3360421-3-andriy.shevchenko@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series iio: initialise ddata for iio_get_acpi_device_name_and_data() | expand

Commit Message

Andy Shevchenko Nov. 1, 2024, 8:08 a.m. UTC
When iio_get_acpi_device_name_and_data() fails, the ddata may be left
uninitialised. Initialise it to NULL.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/54fac4a7-b601-40ce-8c00-d94807f5e214@stanley.mountain
Fixes: 14686836fb69 ("iio: light: isl29018: Replace a variant of iio_get_acpi_device_name_and_data()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/light/isl29018.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Markus Elfring Nov. 1, 2024, 2:27 p.m. UTC | #1
> When iio_get_acpi_device_name_and_data() fails, the ddata may be left
> uninitialised. Initialise it to NULL.

Would a summary phrase like “Assign NULL to ddata in isl29018_probe()” be helpful?


How do you think about a null pointer check also with the local variable “name” instead?

Regards,
Markus
diff mbox series

Patch

diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index cbe34026bda6..201eae1c4589 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -703,7 +703,7 @@  static int isl29018_probe(struct i2c_client *client)
 	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	struct isl29018_chip *chip;
 	struct iio_dev *indio_dev;
-	const void *ddata;
+	const void *ddata = NULL;
 	const char *name;
 	int dev_id;
 	int err;