Thread (2 messages) 2 messages, 2 authors, 2012-10-08
STALE4992d

[PATCH] serial: vt8500: fix possible memory leak in vt8500_serial_probe()

From: Wei Yongjun <hidden>
Date: 2012-10-08 00:47:47
Also in: linux-arm-kernel, linux-serial
Subsystem: arm/vt8500 arm architecture, the rest, tty layer and serial drivers · Maintainers: Alexey Charkov, Krzysztof Kozlowski, Linus Torvalds, Greg Kroah-Hartman, Jiri Slaby

From: Wei Yongjun <redacted>

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.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <redacted>
---
 drivers/tty/serial/vt8500_serial.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 205d4cf..43fc369 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -584,13 +584,16 @@ static int __devinit vt8500_serial_probe(struct platform_device *pdev)
 					sizeof(vt8500_ports_in_use));
 	}
 
-	if (port > VT8500_MAX_PORTS)
-		return -ENODEV;
+	if (port > VT8500_MAX_PORTS) {
+		ret = -ENODEV;
+		goto err;
+	}
 
 	/* reserve the port id */
 	if (test_and_set_bit(port, &vt8500_ports_in_use)) {
 		/* port already in use - shouldn't really happen */
-		return -EBUSY;
+		ret = -EBUSY;
+		goto err;
 	}
 
 	vt8500_port->uart.type = PORT_VT8500;

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help