linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] iio: cros_ec_sensors_core: signedness bug in cros_ec_sensors_read_lpc()
@ 2016-11-10 19:39 Dan Carpenter
  2016-11-10 20:43 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-11-10 19:39 UTC (permalink / raw)
  To: Jonathan Cameron, Enric Balletbo i Serra
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Gwendal Grignou, Guenter Roeck, linux-iio, linux-kernel,
	kernel-janitors

"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.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index a3be799..416cae5 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -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,

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

* Re: [patch] iio: cros_ec_sensors_core: signedness bug in cros_ec_sensors_read_lpc()
  2016-11-10 19:39 [patch] iio: cros_ec_sensors_core: signedness bug in cros_ec_sensors_read_lpc() Dan Carpenter
@ 2016-11-10 20:43 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2016-11-10 20:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jonathan Cameron, Enric Balletbo i Serra, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Gwendal Grignou,
	Guenter Roeck, linux-iio, linux-kernel, kernel-janitors

Hi Dan,

On Thu, Nov 10, 2016 at 11:39 AM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:
> "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.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>

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

Guenter

> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> index a3be799..416cae5 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> @@ -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,

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

end of thread, other threads:[~2016-11-10 20:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10 19:39 [patch] iio: cros_ec_sensors_core: signedness bug in cros_ec_sensors_read_lpc() Dan Carpenter
2016-11-10 20:43 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).