mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH] iio: ak8975: Make sure chipset is always initialized
@ 2014-12-18 17:16 Daniel Baluta
  2014-12-19 22:16 ` Hartmut Knaack
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Baluta @ 2014-12-18 17:16 UTC (permalink / raw)
  To: jic23
  Cc: knaack.h, lars, pmeerw, gwendal, srinivas.pandruvada, beomho.seo,
	daniel.baluta, linux-iio, linux-kernel, octavian.purdila

When using ACPI, if acpi_match_device fails then chipset enum will be
uninitialized and &ak_def_array[chipset] will point to some bad address.

This fixes the following compilation warning:

drivers/iio/magnetometer/ak8975.c: In function ‘ak8975_probe’:
drivers/iio/magnetometer/ak8975.c:788:14: warning: ‘chipset’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
  data->def = &ak_def_array[chipset];

Reported-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
---
This is a RFC because while I'm pretty sure that chipset should be initialized
with AK_MAX_TYPE in ak8975_match_acpi_device, I am not sure if we can live with
a NULL return value of ak8975_match_acpi_device. Current implementation ignores
return value of ak8975_match_acpi_device.

The same situation is for kxcjk-1013, bmc150-accel, bmg160 and possible other
drivers.

 drivers/iio/magnetometer/ak8975.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 0d10a4b..cdf9e77 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -716,6 +716,7 @@ static const char *ak8975_match_acpi_device(struct device *dev,
 {
 	const struct acpi_device_id *id;
 
+	*chipset = AK_MAX_TYPE;
 	id = acpi_match_device(dev->driver->acpi_match_table, dev);
 	if (!id)
 		return NULL;
-- 
1.9.1


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

end of thread, other threads:[~2015-01-24  0:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 17:16 [RFC PATCH] iio: ak8975: Make sure chipset is always initialized Daniel Baluta
2014-12-19 22:16 ` Hartmut Knaack
2014-12-19 22:25   ` Daniel Baluta
2014-12-20 21:26     ` Srinivas Pandruvada
2014-12-20 21:29       ` Pandruvada, Srinivas
2014-12-20 21:40         ` Daniel Baluta
2015-01-19 14:40         ` Daniel Baluta
2015-01-19 16:44           ` Pandruvada, Srinivas
2015-01-19 16:49             ` Daniel Baluta
2015-01-19 16:56               ` Pandruvada, Srinivas
2015-01-23 23:38                 ` Hartmut Knaack
2015-01-24  0:17                   ` Pandruvada, Srinivas

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®