Skip to content

Commit

Permalink
SERIAL: ioc3_serial: Return -ENOMEM on memory allocation failure
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and Ralf Baechle committed Oct 19, 2010
1 parent 08be7b2 commit 6cc0cc4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/serial/ioc3_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6cc0cc4

Please sign in to comment.