mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: adc: pac1934: Return -ENOMEM on memory allocation failure
@ 2026-02-11 17:10 Antoniu Miclaus
  2026-02-11 17:38 ` Andy Shevchenko
  2026-02-14 19:34 ` Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: Antoniu Miclaus @ 2026-02-11 17:10 UTC (permalink / raw)
  To: Marius Cristea, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Lars-Peter Clausen, Michael Hennerich,
	linux-iio, linux-kernel
  Cc: Antoniu Miclaus

devm_kzalloc() returns NULL on allocation failure. The appropriate error
code for this condition is -ENOMEM, not -EINVAL.

Fixes: 0fb528c8255b ("iio: adc: adding support for PAC193x")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/adc/pac1934.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/pac1934.c b/drivers/iio/adc/pac1934.c
index ec96bb0f2ed6..b791ce23f3fd 100644
--- a/drivers/iio/adc/pac1934.c
+++ b/drivers/iio/adc/pac1934.c
@@ -1351,7 +1351,7 @@ static int pac1934_prep_iio_channels(struct pac1934_chip_info *info, struct iio_
 
 	dyn_ch_struct = devm_kzalloc(dev, channel_size, GFP_KERNEL);
 	if (!dyn_ch_struct)
-		return -EINVAL;
+		return -ENOMEM;
 
 	tmp_data = dyn_ch_struct;
 
-- 
2.43.0


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

* Re: [PATCH] iio: adc: pac1934: Return -ENOMEM on memory allocation failure
  2026-02-11 17:10 [PATCH] iio: adc: pac1934: Return -ENOMEM on memory allocation failure Antoniu Miclaus
@ 2026-02-11 17:38 ` Andy Shevchenko
  2026-02-14 19:34 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-02-11 17:38 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Marius Cristea, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Lars-Peter Clausen, Michael Hennerich,
	linux-iio, linux-kernel

On Wed, Feb 11, 2026 at 7:10 PM Antoniu Miclaus
<antoniu.miclaus@analog.com> wrote:
>
> devm_kzalloc() returns NULL on allocation failure. The appropriate error
> code for this condition is -ENOMEM, not -EINVAL.

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

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] iio: adc: pac1934: Return -ENOMEM on memory allocation failure
  2026-02-11 17:10 [PATCH] iio: adc: pac1934: Return -ENOMEM on memory allocation failure Antoniu Miclaus
  2026-02-11 17:38 ` Andy Shevchenko
@ 2026-02-14 19:34 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-02-14 19:34 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Lars-Peter Clausen, Michael Hennerich,
	linux-iio, linux-kernel

On Wed, 11 Feb 2026 19:10:05 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:

> devm_kzalloc() returns NULL on allocation failure. The appropriate error
> code for this condition is -ENOMEM, not -EINVAL.
> 
> Fixes: 0fb528c8255b ("iio: adc: adding support for PAC193x")

Given it's a small alloc and in practice those don't fail if you machine
is likely to boot and at worst you get a slightly misleading error code,
I don't think backports are appropriate, so I've applied this
dropping the fixes tag.


> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
>  drivers/iio/adc/pac1934.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/pac1934.c b/drivers/iio/adc/pac1934.c
> index ec96bb0f2ed6..b791ce23f3fd 100644
> --- a/drivers/iio/adc/pac1934.c
> +++ b/drivers/iio/adc/pac1934.c
> @@ -1351,7 +1351,7 @@ static int pac1934_prep_iio_channels(struct pac1934_chip_info *info, struct iio_
>  
>  	dyn_ch_struct = devm_kzalloc(dev, channel_size, GFP_KERNEL);
>  	if (!dyn_ch_struct)
> -		return -EINVAL;
> +		return -ENOMEM;
>  
>  	tmp_data = dyn_ch_struct;
>  


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

end of thread, other threads:[~2026-02-14 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-11 17:10 [PATCH] iio: adc: pac1934: Return -ENOMEM on memory allocation failure Antoniu Miclaus
2026-02-11 17:38 ` Andy Shevchenko
2026-02-14 19:34 ` Jonathan Cameron

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

all inboxes | Powered by JetHome®