Skip to contentSkip to conversation

iio: cros_ec_sensors_core: signedness bug in cros_ec_sensors_read_lpc()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 10, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: cros_ec_sensors_core: signedness bug in cros_ec_sensors_read_lpc()

"status" is a u8 so checking for negatives doesn't work. We can just use "ret" here instead.

Fixes 974e6f02e27e ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.")
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +4 -4
index a3be799..416cae5 100644
@@ -291,15 +291,15 @@ int cros_ec_sensors_read_lpc(struct iio_dev *indio_dev,
 			return -EIO;
 
 		/* Read status byte until EC is not busy. */
-		status = cros_ec_sensors_read_until_not_busy(st);
-		if (status < 0)
-			return status;
+		ret = cros_ec_sensors_read_until_not_busy(st);
+		if (ret < 0)
+			return ret;
 
 		/*
 		 * Store the current sample id so that we can compare to the
 		 * sample id after reading the data.
 		 */
-		samp_id = status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
+		samp_id = ret & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
 
 		/* Read all EC data, format it, and store it into data. */
 		ret = cros_ec_sensors_read_data_unsafe(indio_dev, scan_mask,
#1 lore raw

Hi Dan,

Quoted 6 lines · Dan Carpenter

"status" is a u8 so checking for negatives doesn't work. We can just use "ret" here instead.

Fixes 974e6f02e27e ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.")

Also fixed with https://lkml.org/lkml/2016/11/9/807

Guenter

Quoted 24 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +4 -4
index a3be799..416cae5 100644
@@ -291,15 +291,15 @@ int cros_ec_sensors_read_lpc(struct iio_dev *indio_dev,
                        return -EIO;
 
                /* Read status byte until EC is not busy. */
-               status = cros_ec_sensors_read_until_not_busy(st);
-               if (status < 0)
-                       return status;
+               ret = cros_ec_sensors_read_until_not_busy(st);
+               if (ret < 0)
+                       return ret;
 
                /*
                 * Store the current sample id so that we can compare to the
                 * sample id after reading the data.
                 */
-               samp_id = status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
+               samp_id = ret & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
 
                /* Read all EC data, format it, and store it into data. */
                ret = cros_ec_sensors_read_data_unsafe(indio_dev, scan_mask,