]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
SERIAL: ioc3_serial: Return -ENOMEM on memory allocation failure
authorJulia Lawall <julia@diku.dk>
Fri, 15 Oct 2010 13:00:09 +0000 (15:00 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 19 Oct 2010 17:32:40 +0000 (18:32 +0100)
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>
To: Pat Gefre <pfg@sgi.com>
Cc: kernel-janitors@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/1704/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
drivers/serial/ioc3_serial.c

index 93de907b12088a54ab5809cf79c46ba5ec2757f2..800c54602339780cc79d615e16fb89f49bf3d5f5 100644 (file)
@@ -2044,6 +2044,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
                if (!port) {
                        printk(KERN_WARNING
                               "IOC3 serial memory not available for port\n");
+                       ret = -ENOMEM;
                        goto out4;
                }
                spin_lock_init(&port->ip_lock);