public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: addac: ad74115: Add missing check for device_property_read_u32_array
@ 2026-01-28  4:30 Chen Ni
  2026-01-28  9:34 ` Nuno Sá
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Ni @ 2026-01-28  4:30 UTC (permalink / raw)
  To: lars, Michael.Hennerich, cosmin.tanislav, jic23, dlechner,
	nuno.sa, andy
  Cc: linux-iio, linux-kernel, Chen Ni

Add check for the return value of device_property_read_u32_array() and
return the error if it fails in order to catch the error.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/iio/addac/ad74115.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/addac/ad74115.c b/drivers/iio/addac/ad74115.c
index f8b04d86b01f..d0d6c0575ff1 100644
--- a/drivers/iio/addac/ad74115.c
+++ b/drivers/iio/addac/ad74115.c
@@ -1515,8 +1515,12 @@ static int ad74115_setup_adc_conv2_range(struct ad74115_state *st)
 	};
 	struct device *dev = &st->spi->dev;
 	unsigned int i;
+	int ret;
 
-	device_property_read_u32_array(dev, prop_name, vals, 2);
+	ret = device_property_read_u32_array(dev, prop_name, vals, 2);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to read %s prop\n",
+				     prop_name);
 
 	for (i = 0; i < tbl_len; i++)
 		if (vals[0] == ad74115_adc_range_tbl[i][0] &&
-- 
2.25.1


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

* Re: [PATCH] iio: addac: ad74115: Add missing check for device_property_read_u32_array
  2026-01-28  4:30 [PATCH] iio: addac: ad74115: Add missing check for device_property_read_u32_array Chen Ni
@ 2026-01-28  9:34 ` Nuno Sá
  2026-01-28  9:41   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Nuno Sá @ 2026-01-28  9:34 UTC (permalink / raw)
  To: Chen Ni, lars, Michael.Hennerich, cosmin.tanislav, jic23,
	dlechner, nuno.sa, andy
  Cc: linux-iio, linux-kernel

On Wed, 2026-01-28 at 12:30 +0800, Chen Ni wrote:
> Add check for the return value of device_property_read_u32_array() and
> return the error if it fails in order to catch the error.
> 
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/iio/addac/ad74115.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/addac/ad74115.c b/drivers/iio/addac/ad74115.c
> index f8b04d86b01f..d0d6c0575ff1 100644
> --- a/drivers/iio/addac/ad74115.c
> +++ b/drivers/iio/addac/ad74115.c
> @@ -1515,8 +1515,12 @@ static int ad74115_setup_adc_conv2_range(struct ad74115_state *st)
>  	};
>  	struct device *dev = &st->spi->dev;
>  	unsigned int i;
> +	int ret;
>  
> -	device_property_read_u32_array(dev, prop_name, vals, 2);
> +	ret = device_property_read_u32_array(dev, prop_name, vals, 2);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to read %s prop\n",
> +				     prop_name);

Thanks for the patch but this is intentional. Not a mandatory property. If you want, you could
do

if (ret && ret != -EINVAL)
	return dev_err_probe()

Not 100% sure if that is the proper error code but the goal is to only error out in case the
property __is__ present but wrong. However we are kind of relaxed with the above in IIO.

- Nuno Sá
> 

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

* Re: [PATCH] iio: addac: ad74115: Add missing check for device_property_read_u32_array
  2026-01-28  9:34 ` Nuno Sá
@ 2026-01-28  9:41   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-01-28  9:41 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Chen Ni, lars, Michael.Hennerich, cosmin.tanislav, jic23,
	dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Wed, Jan 28, 2026 at 09:34:18AM +0000, Nuno Sá wrote:
> On Wed, 2026-01-28 at 12:30 +0800, Chen Ni wrote:
> > Add check for the return value of device_property_read_u32_array() and
> > return the error if it fails in order to catch the error.

...

> > -	device_property_read_u32_array(dev, prop_name, vals, 2);
> > +	ret = device_property_read_u32_array(dev, prop_name, vals, 2);
> > +	if (ret)
> > +		return dev_err_probe(dev, ret, "Failed to read %s prop\n",
> > +				     prop_name);
> 
> Thanks for the patch but this is intentional. Not a mandatory property.

No need for further actions. NAK to the change. We don't want to have a monster
with the custom error checking.

P.S. The author also must answer if this was found by some static analyser
tool. If so, the stream from this "tool" should be blocked for now.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-01-28  9:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28  4:30 [PATCH] iio: addac: ad74115: Add missing check for device_property_read_u32_array Chen Ni
2026-01-28  9:34 ` Nuno Sá
2026-01-28  9:41   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox