summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/sh-sci.c
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2016-12-03 18:40:25 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-12 11:51:24 +0100
commit623ac1d4a52f279d9379bae61ae1eb37c5767f96 (patch)
tree59b7d58d020565db0c543fe63c043541cfc70ff1 /drivers/tty/serial/sh-sci.c
parenta121103c922847ba5010819a3f250f1f7fc84ab8 (diff)
downloadlinux-623ac1d4a52f279d9379bae61ae1eb37c5767f96.tar.bz2
tty: serial: sh-sci: set error code when kasprintf fails
When the call to kasprintf() returns a NULL pointer, function sci_request_irq() frees the preallocated memory and returns 0 is returned. Because 0 means no error, the caller of sci_request_irq() will keep going, and the freed memory may be used or freed again. To avoid the above issue, this patch assigns "-ENOMEM" to the return variable ret. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188691 Signed-off-by: Pan Bian <bianpan2016@163.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/sh-sci.c')
-rw-r--r--drivers/tty/serial/sh-sci.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 91e7dddbf72c..b33199af8877 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1743,8 +1743,10 @@ static int sci_request_irq(struct sci_port *port)
desc = sci_irq_desc + i;
port->irqstr[j] = kasprintf(GFP_KERNEL, "%s:%s",
dev_name(up->dev), desc->desc);
- if (!port->irqstr[j])
+ if (!port->irqstr[j]) {
+ ret = -ENOMEM;
goto out_nomem;
+ }
ret = request_irq(irq, desc->handler, up->irqflags,
port->irqstr[j], port);