linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6/7] drivers/serial/ioc3_serial.c: Return -ENOMEM on memory allocation failure
@ 2010-10-15 13:00 Julia Lawall
  2010-10-15 14:08 ` Ralf Baechle
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-10-15 13:00 UTC (permalink / raw)
  To: Pat Gefre; +Cc: kernel-janitors, linux-ia64, linux-mips, linux-kernel

From: Julia Lawall <julia@diku.dk>

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>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/serial/ioc3_serial.c |    1 +
 1 file changed, 1 insertion(+)

diff -u -p a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
--- 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);


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

* Re: [PATCH 6/7] drivers/serial/ioc3_serial.c: Return -ENOMEM on memory allocation failure
  2010-10-15 13:00 [PATCH 6/7] drivers/serial/ioc3_serial.c: Return -ENOMEM on memory allocation failure Julia Lawall
@ 2010-10-15 14:08 ` Ralf Baechle
  0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2010-10-15 14:08 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Pat Gefre, kernel-janitors, linux-ia64, linux-mips, linux-kernel

On Fri, Oct 15, 2010 at 03:00:09PM +0200, Julia Lawall wrote:

> From: Julia Lawall <julia@diku.dk>
> 
> 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

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

end of thread, other threads:[~2010-10-15 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-15 13:00 [PATCH 6/7] drivers/serial/ioc3_serial.c: Return -ENOMEM on memory allocation failure Julia Lawall
2010-10-15 14:08 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).