2022-06-13 23:25:47

by Stephen Boyd

[permalink] [raw]
Subject: [PATCH] iio:proximity:sx9324: Check ret value of device_property_read_u32_array()

From: Aashish Sharma <[email protected]>

0-day reports:

drivers/iio/proximity/sx9324.c:868:3: warning: Value stored
to 'ret' is never read [clang-analyzer-deadcode.DeadStores]

Put an if condition to break out of switch if ret is non-zero.

Signed-off-by: Aashish Sharma <[email protected]>
Fixes: a8ee3b32f5da ("iio:proximity:sx9324: Add dt_binding support")
Reported-by: kernel test robot <[email protected]>
[[email protected]: Reword commit subject, add fixes tag]
Signed-off-by: Stephen Boyd <[email protected]>
---
drivers/iio/proximity/sx9324.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index 70c37f664f6d..63fbcaa4cac8 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -885,6 +885,9 @@ sx9324_get_default_reg(struct device *dev, int idx,
break;
ret = device_property_read_u32_array(dev, prop, pin_defs,
ARRAY_SIZE(pin_defs));
+ if (ret)
+ break;
+
for (pin = 0; pin < SX9324_NUM_PINS; pin++)
raw |= (pin_defs[pin] << (2 * pin)) &
SX9324_REG_AFE_PH0_PIN_MASK(pin);

base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
--
https://chromeos.dev


2022-06-13 23:35:57

by Gwendal Grignou

[permalink] [raw]
Subject: Re: [PATCH] iio:proximity:sx9324: Check ret value of device_property_read_u32_array()

On Mon, Jun 13, 2022 at 4:22 PM Stephen Boyd <[email protected]> wrote:
>
> From: Aashish Sharma <[email protected]>
>
> 0-day reports:
>
> drivers/iio/proximity/sx9324.c:868:3: warning: Value stored
> to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
>
> Put an if condition to break out of switch if ret is non-zero.
>
> Signed-off-by: Aashish Sharma <[email protected]>
> Fixes: a8ee3b32f5da ("iio:proximity:sx9324: Add dt_binding support")
> Reported-by: kernel test robot <[email protected]>
> [[email protected]: Reword commit subject, add fixes tag]
> Signed-off-by: Stephen Boyd <[email protected]>
Reviewed-by: Gwendal Grignou <[email protected]>
> ---
> drivers/iio/proximity/sx9324.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
> index 70c37f664f6d..63fbcaa4cac8 100644
> --- a/drivers/iio/proximity/sx9324.c
> +++ b/drivers/iio/proximity/sx9324.c
> @@ -885,6 +885,9 @@ sx9324_get_default_reg(struct device *dev, int idx,
> break;
> ret = device_property_read_u32_array(dev, prop, pin_defs,
> ARRAY_SIZE(pin_defs));
> + if (ret)
> + break;
> +
> for (pin = 0; pin < SX9324_NUM_PINS; pin++)
> raw |= (pin_defs[pin] << (2 * pin)) &
> SX9324_REG_AFE_PH0_PIN_MASK(pin);
>
> base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
> --
> https://chromeos.dev
>

2022-06-18 17:08:45

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH] iio:proximity:sx9324: Check ret value of device_property_read_u32_array()

On Mon, 13 Jun 2022 16:25:55 -0700
Gwendal Grignou <[email protected]> wrote:

> On Mon, Jun 13, 2022 at 4:22 PM Stephen Boyd <[email protected]> wrote:
> >
> > From: Aashish Sharma <[email protected]>
> >
> > 0-day reports:
> >
> > drivers/iio/proximity/sx9324.c:868:3: warning: Value stored
> > to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
> >
> > Put an if condition to break out of switch if ret is non-zero.
> >
> > Signed-off-by: Aashish Sharma <[email protected]>
> > Fixes: a8ee3b32f5da ("iio:proximity:sx9324: Add dt_binding support")
> > Reported-by: kernel test robot <[email protected]>
> > [[email protected]: Reword commit subject, add fixes tag]
> > Signed-off-by: Stephen Boyd <[email protected]>
> Reviewed-by: Gwendal Grignou <[email protected]>
Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> > ---
> > drivers/iio/proximity/sx9324.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
> > index 70c37f664f6d..63fbcaa4cac8 100644
> > --- a/drivers/iio/proximity/sx9324.c
> > +++ b/drivers/iio/proximity/sx9324.c
> > @@ -885,6 +885,9 @@ sx9324_get_default_reg(struct device *dev, int idx,
> > break;
> > ret = device_property_read_u32_array(dev, prop, pin_defs,
> > ARRAY_SIZE(pin_defs));
> > + if (ret)
> > + break;
> > +
> > for (pin = 0; pin < SX9324_NUM_PINS; pin++)
> > raw |= (pin_defs[pin] << (2 * pin)) &
> > SX9324_REG_AFE_PH0_PIN_MASK(pin);
> >
> > base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
> > --
> > https://chromeos.dev
> >