iio: imu: check sscanf return value
authorIoana Ciornei <ciorneiioana@gmail.com>
Sun, 1 Nov 2015 12:58:45 +0000 (14:58 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 8 Nov 2015 15:44:10 +0000 (15:44 +0000)
This patch fixes the following checkpatch warning:
WARNING: unchecked sscanf return value

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/imu/adis16400_core.c
drivers/iio/imu/adis16480.c

index abc4c50de9e8b334548560c593f6c53c5bba675c..72bcc2491d1dd1d4a0942706b3e27620158c53b6 100644 (file)
@@ -288,7 +288,11 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
                if (ret)
                        goto err_ret;
 
-               sscanf(indio_dev->name, "adis%u\n", &device_id);
+               ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
+               if (ret != 1) {
+                       ret = -EINVAL;
+                       goto err_ret;
+               }
 
                if (prod_id != device_id)
                        dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.",
index b94bfd3f595bfad7e091bda7639d35b30b4e6bc4..16d430461414a2f49c64f110d66b597ee3c98471 100644 (file)
@@ -765,7 +765,9 @@ static int adis16480_initial_setup(struct iio_dev *indio_dev)
        if (ret)
                return ret;
 
-       sscanf(indio_dev->name, "adis%u\n", &device_id);
+       ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
+       if (ret != 1)
+               return -EINVAL;
 
        if (prod_id != device_id)
                dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.",