diff options
author | Wei Yongjun <yongjun_wei@trendmicro.com.cn> | 2012-10-07 22:35:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-24 14:34:51 -0400 |
commit | 59c2e855e43735f4ab93b8b8db96206219f6c1d4 (patch) | |
tree | 86eb4bdf02a007a9d79ae70122a69462f002a22e /drivers/tty/serial | |
parent | 54ec52b6dd3b0ba4bc4eb97e7e1b2534705b326c (diff) |
serial: vt8500: fix possible memory leak in vt8500_serial_probe()
vt8500_port is malloced in vt8500_serial_probe() and should be freed
before leaving from the error handling cases, otherwise it will
cause memory leak.
Fix it by move the allocation of vt8500_port after those test.
dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Acked-by: Tony Prisk <linux@prisktech.co.nz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r-- | drivers/tty/serial/vt8500_serial.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 205d4cf4a063..4354fe565f64 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c | |||
@@ -567,10 +567,6 @@ static int __devinit vt8500_serial_probe(struct platform_device *pdev) | |||
567 | if (!mmres || !irqres) | 567 | if (!mmres || !irqres) |
568 | return -ENODEV; | 568 | return -ENODEV; |
569 | 569 | ||
570 | vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL); | ||
571 | if (!vt8500_port) | ||
572 | return -ENOMEM; | ||
573 | |||
574 | if (np) | 570 | if (np) |
575 | port = of_alias_get_id(np, "serial"); | 571 | port = of_alias_get_id(np, "serial"); |
576 | if (port > VT8500_MAX_PORTS) | 572 | if (port > VT8500_MAX_PORTS) |
@@ -593,6 +589,10 @@ static int __devinit vt8500_serial_probe(struct platform_device *pdev) | |||
593 | return -EBUSY; | 589 | return -EBUSY; |
594 | } | 590 | } |
595 | 591 | ||
592 | vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL); | ||
593 | if (!vt8500_port) | ||
594 | return -ENOMEM; | ||
595 | |||
596 | vt8500_port->uart.type = PORT_VT8500; | 596 | vt8500_port->uart.type = PORT_VT8500; |
597 | vt8500_port->uart.iotype = UPIO_MEM; | 597 | vt8500_port->uart.iotype = UPIO_MEM; |
598 | vt8500_port->uart.mapbase = mmres->start; | 598 | vt8500_port->uart.mapbase = mmres->start; |