Skip to contentSkip to conversation

iio: adc: pac1934: Return -ENOMEM on memory allocation failure

PATCH In review Antoniu Miclaus 3 participants 3 messages Feb 11 – Feb 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: pac1934: Return -ENOMEM on memory allocation failure

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")
---
 drivers/iio/adc/pac1934.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/pac1934.c +1 -1
index ec96bb0f2ed6..b791ce23f3fd 100644
@@ -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;
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Antoniu Miclaus

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#2 lore raw
In reply to Antoniu Miclaus
Quoted 4 lines · On Wed, 11 Feb 2026 19:10:05 +0200 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")

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.

Quoted 18 lines
---
 drivers/iio/adc/pac1934.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/pac1934.c +1 -1
index ec96bb0f2ed6..b791ce23f3fd 100644
@@ -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;