Skip to contentSkip to conversation

drivers/serial/ioc3_serial.c: Return -ENOMEM on memory allocation failure

PATCH In review Julia Lawall 2 participants 2 messages Oct 15, 2010

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

PATCH 6/7 drivers/serial/ioc3_serial.c: Return -ENOMEM on memory allocation failure

From: Julia Lawall <[email protected]>

In this code, 0 is returned on memory allocation failure, even though other failures return -ENOMEM or other similar values.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression ret;
expression x,e1,e2,e3;
@@

ret = 0
... when != ret = e1
*x = \(kmalloc\|kcalloc\|kzalloc\)(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
return ret;
}
// </smpl>

---
 drivers/serial/ioc3_serial.c |    1 +
 1 file changed, 1 insertion(+)
drivers/serial/ioc3_serial.c +1 -0
diff -u -p a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
@@ -2045,6 +2045,7 @@ ioc3uart_probe(struct ioc3_submodule *is
 		if (!port) {
 			printk(KERN_WARNING
 			       "IOC3 serial memory not available for port\n");
+			ret = -ENOMEM;
 			goto out4;
 		}
 		spin_lock_init(&port->ip_lock);
#1 lore raw
Quoted 7 lines · Julia Lawall

From: Julia Lawall <[email protected]>

In this code, 0 is returned on memory allocation failure, even though other failures return -ENOMEM or other similar values.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

Dunno why linux-mips rsp. myself keep receiving patches for the ioc3 serial driver - it's only being used on SGI IA64 machines.

Either way, I'm willing to funnel this patch upstream - I'm building a pull rq for tonight anyway.

Ralf