Skip to contentSkip to conversation

CAPI: return -ENOMEM when kmalloc failed

PATCH In review Jiapeng Chong 2 participants 2 messages Mar 14, 2024

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

PATCH 1/1 CAPI: return -ENOMEM when kmalloc failed

The driver is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed.

drivers/isdn/capi/capi.c:154 capiminor_add_ack() warn: returning -1 instead of -ENOMEM is sloppy.

---
 drivers/isdn/capi/capi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/isdn/capi/capi.c +1 -1
index 3ed257334562..b6764313fbdb 100644
@@ -151,7 +151,7 @@ static int capiminor_add_ack(struct capiminor *mp, u16 datahandle)
 	n = kmalloc(sizeof(*n), GFP_ATOMIC);
 	if (unlikely(!n)) {
 		printk(KERN_ERR "capi: alloc datahandle failed\n");
-		return -1;
+		return -ENOMEM;
 	}
 	n->datahandle = datahandle;
 	INIT_LIST_HEAD(&n->list);
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 8 lines · Jiapeng Chong

The driver is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed.

drivers/isdn/capi/capi.c:154 capiminor_add_ack() warn: returning -1 instead of -ENOMEM is sloppy.

The patch itself looks reasonable. The caller only cares about is the return code negative or not. So returning -ENOMEM or -1 makes no difference.

Please take a look at:

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

You need to specify a tree you want this merged via.

If you consider this a fix, you need to add a Fixes: tag. However, i don't see this patch meeting stable requirements.

If this is just normal development, net-next is closed at the moment for the merge window. Please repost in two weeks time.

Andrew