Re: [PATCH 2/2] iio: imu: check sscanf return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/11/15 12:58, Ioana Ciornei wrote:
> This patch fixes the following checkpatch warning:
> WARNING: unchecked sscanf return value
> 
> Signed-off-by: Ioana Ciornei <ciorneiioana@xxxxxxxxx>
Applied to the togreg branch of stating - initially pushed
out as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
> 
> based on linux-iio testing branch
> 
>  drivers/iio/imu/adis16400_core.c | 6 +++++-
>  drivers/iio/imu/adis16480.c      | 4 +++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
> index abc4c50..72bcc24 100644
> --- a/drivers/iio/imu/adis16400_core.c
> +++ b/drivers/iio/imu/adis16400_core.c
> @@ -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.",
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index b94bfd3..16d4304 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -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.",
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux