From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julia Lawall Date: Fri, 15 Oct 2010 12:54:48 +0000 Subject: [PATCH 6/7] drivers/serial/ioc3_serial.c: Return -ENOMEM on memory allocation failure Message-Id: <1287147610-8041-6-git-send-email-julia@diku.dk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Pat Gefre Cc: kernel-janitors@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org From: Julia Lawall 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/) // @@ 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; } // Signed-off-by: Julia Lawall --- 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);