diff mbox series

[v2,1/4] iio: light: ltr501: Assing ddata to NULL

Message ID 20241101081203.3360421-2-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: 61da460b813d ("iio: light: ltr501: Replace a variant of iio_get_acpi_device_name_and_data()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/light/ltr501.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

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

Would you like to use the summary phrase “Assign NULL to ddata in ltr501_probe()” accordingly?

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

How do you think about to perform the variable assignment only in
a corresponding else branch?

Can it be that this adjustment does not really matter here because of
the following statement?

	if (!name)
		return -ENODEV;


Regards,
Markus
diff mbox series

Patch

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 7228611d4c59..616dc6921702 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -1424,8 +1424,8 @@  static int ltr501_probe(struct i2c_client *client)
 	struct ltr501_data *data;
 	struct iio_dev *indio_dev;
 	struct regmap *regmap;
+	const void *ddata = NULL;
 	int partid, chip_idx;
-	const void *ddata;
 	const char *name;
 	int ret;