[PATCH] iio: frequency: adf4350: Return -ENOMEM on memory allocation failure

Antoniu Miclaus posted 1 patch 1 month, 2 weeks ago
drivers/iio/frequency/adf4350.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] iio: frequency: adf4350: Return -ENOMEM on memory allocation failure
Posted by Antoniu Miclaus 1 month, 2 weeks ago
adf4350_parse_dt() returns NULL only when devm_kzalloc() fails. The
caller should return -ENOMEM in this case, not -EINVAL.

Fixes: e764df679639 ("iio: frequency: adf4350: Add support for dt bindings")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/frequency/adf4350.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
index ed1741165f55..3883b63dcc3c 100644
--- a/drivers/iio/frequency/adf4350.c
+++ b/drivers/iio/frequency/adf4350.c
@@ -607,7 +607,7 @@ static int adf4350_probe(struct spi_device *spi)
 	if (dev_fwnode(&spi->dev)) {
 		pdata = adf4350_parse_dt(&spi->dev);
 		if (pdata == NULL)
-			return -EINVAL;
+			return -ENOMEM;
 	} else {
 		pdata = dev_get_platdata(&spi->dev);
 	}
-- 
2.43.0
Re: [PATCH] iio: frequency: adf4350: Return -ENOMEM on memory allocation failure
Posted by Andy Shevchenko 1 month, 2 weeks ago
On Wed, Feb 11, 2026 at 7:10 PM Antoniu Miclaus
<antoniu.miclaus@analog.com> wrote:
>
> adf4350_parse_dt() returns NULL only when devm_kzalloc() fails. The
> caller should return -ENOMEM in this case, not -EINVAL.

Right, and the memory allocator dumps enough info if it happens.
Reviewed-by: Andy Shevchenko <andy@kernel.org>

...

>                 pdata = dev_get_platdata(&spi->dev);

Side note: Have you considered killing legacy platform data?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] iio: frequency: adf4350: Return -ENOMEM on memory allocation failure
Posted by Jonathan Cameron 1 month, 2 weeks ago
On Wed, 11 Feb 2026 19:39:43 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Wed, Feb 11, 2026 at 7:10 PM Antoniu Miclaus
> <antoniu.miclaus@analog.com> wrote:
> >
> > adf4350_parse_dt() returns NULL only when devm_kzalloc() fails. The
> > caller should return -ENOMEM in this case, not -EINVAL.  
> 
> Right, and the memory allocator dumps enough info if it happens.
> Reviewed-by: Andy Shevchenko <andy@kernel.org>
I dropped the fixes tag as seems inappropriate for something that doesn't
happen except in the death throws of a platform and where it only gave
a wrong error code.  With that gone, applied.

Thanks,

Jonathan

> 
> ...
> 
> >                 pdata = dev_get_platdata(&spi->dev);  
> 
> Side note: Have you considered killing legacy platform data?
>