All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adis16400: Fix an error code in adis16400_initial_setup()
@ 2021-02-16 19:42 Dan Carpenter
  2021-02-21 15:26 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-02-16 19:42 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Michael Hennerich, Jonathan Cameron, Peter Meerwald-Stadler,
	Ioana Ciornei, linux-iio, linux-kernel, kernel-janitors

This is to silence a new Smatch warning:

    drivers/iio/imu/adis16400.c:492 adis16400_initial_setup()
    warn: sscanf doesn't return error codes

If the condition "if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {"
is false then we return 1 instead of returning 0 and probe will fail.

Fixes: 72a868b38bdd ("iio: imu: check sscanf return value")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/iio/imu/adis16400.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
index 54af2ed664f6..785a4ce606d8 100644
--- a/drivers/iio/imu/adis16400.c
+++ b/drivers/iio/imu/adis16400.c
@@ -462,8 +462,7 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
 		if (ret)
 			goto err_ret;
 
-		ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
-		if (ret != 1) {
+		if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) {
 			ret = -EINVAL;
 			goto err_ret;
 		}
-- 
2.30.0


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

* Re: [PATCH] iio: adis16400: Fix an error code in adis16400_initial_setup()
  2021-02-16 19:42 [PATCH] iio: adis16400: Fix an error code in adis16400_initial_setup() Dan Carpenter
@ 2021-02-21 15:26 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2021-02-21 15:26 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Lars-Peter Clausen, Michael Hennerich, Peter Meerwald-Stadler,
	Ioana Ciornei, linux-iio, linux-kernel, kernel-janitors

On Tue, 16 Feb 2021 22:42:13 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> This is to silence a new Smatch warning:
> 
>     drivers/iio/imu/adis16400.c:492 adis16400_initial_setup()
>     warn: sscanf doesn't return error codes
> 
> If the condition "if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {"
> is false then we return 1 instead of returning 0 and probe will fail.
> 
> Fixes: 72a868b38bdd ("iio: imu: check sscanf return value")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Hi Dan,

May be worth a follow up at some point to get rid of the silliness
of goto err_ret by using direct returns.  Obviously that is a rather
less minimal fix however so not so good for backports.

Hence, applied this to the fixes-togreg branch of iio.git and marked
for stable. 

Thanks,


Jonathan

> ---
>  drivers/iio/imu/adis16400.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
> index 54af2ed664f6..785a4ce606d8 100644
> --- a/drivers/iio/imu/adis16400.c
> +++ b/drivers/iio/imu/adis16400.c
> @@ -462,8 +462,7 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
>  		if (ret)
>  			goto err_ret;
>  
> -		ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
> -		if (ret != 1) {
> +		if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) {
>  			ret = -EINVAL;
>  			goto err_ret;
>  		}


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

end of thread, other threads:[~2021-02-21 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 19:42 [PATCH] iio: adis16400: Fix an error code in adis16400_initial_setup() Dan Carpenter
2021-02-21 15:26 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.