iio:magnetometer:ak8975: fix uninitialized chipset
authorGregor Boirie <gregor.boirie@parrot.com>
Thu, 3 Mar 2016 10:44:03 +0000 (11:44 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sat, 5 Mar 2016 15:18:05 +0000 (15:18 +0000)
ak_def_array bounds are not properly checked in case of ACPI matching
failure. GCC warns with the following message at line 799:
‘chipset’ may be used uninitialized in this function.

Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/magnetometer/ak8975.c

index 9c5c9ef3f1dad25f37e108aeb9752940f46aa393..11059b2c39a413e27cc39790aed0aae243dc2cbf 100644 (file)
@@ -774,8 +774,11 @@ static int ak8975_probe(struct i2c_client *client,
        if (id) {
                chipset = (enum asahi_compass_chipset)(id->driver_data);
                name = id->name;
-       } else if (ACPI_HANDLE(&client->dev))
+       } else if (ACPI_HANDLE(&client->dev)) {
                name = ak8975_match_acpi_device(&client->dev, &chipset);
+               if (!name)
+                       return -ENODEV;
+       }
        else
                return -ENOSYS;