Skip to content

Commit 6cc0cc4

Browse files
Julia Lawallralfbaechle
authored andcommitted
SERIAL: ioc3_serial: Return -ENOMEM on memory allocation failure
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>
1 parent 08be7b2 commit 6cc0cc4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/serial/ioc3_serial.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,6 +2044,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
20442044
if (!port) {
20452045
printk(KERN_WARNING
20462046
"IOC3 serial memory not available for port\n");
2047+
ret = -ENOMEM;
20472048
goto out4;
20482049
}
20492050
spin_lock_init(&port->ip_lock);

0 commit comments

Comments
 (0)