lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 9 Nov 2016 19:16:32 -0800
From:   Guenter Roeck <groeck@...gle.com>
To:     Colin King <colin.king@...onical.com>
Cc:     Jonathan Cameron <jic23@...nel.org>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        Guenter Roeck <groeck@...omium.org>,
        Gwendal Grignou <gwendal@...omium.org>,
        Enric Balletbo i Serra <enric.balletbo@...labora.com>,
        linux-iio@...r.kernel.org,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] iio: cros_ec_sensors_core: fix unsigned compared less
 than zero on status

On Wed, Nov 9, 2016 at 3:12 PM, Colin King <colin.king@...onical.com> wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> status is a u8 hence the check if status is less than zero has no effect.
> Fix this by replacing status with int ret so the less than zero compare
> will correctly detect errors.
>
> Issue found with static analysis with CoverityScan, CID 1375919
>
> Signed-off-by: Colin Ian King <colin.king@...onical.com>

Good catch!

Fixes: 974e6f02e27e ("iio: cros_ec_sensors_core: Add common functions
for the ChromeOS EC Sensor Hub")
Reviewed-by: Guenter Roeck <groeck@...omium.org>

For the benefit of others, this is in today's linux-next.

Thanks,
Guenter

> ---
>  drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> 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,
> --
> 2.10.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ