From 55f2291142efa42acab362bf71b52e03bd275a42 Mon Sep 17 00:00:00 2001 From: Phong Tran Date: Mon, 1 Jun 2015 22:19:45 +0700 Subject: [PATCH] greybus: uart: Fix the memory leak in connection init If alloc minor is error, gb_tty should free. Signed-off-by: Phong Tran Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/uart.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c index 47de9698f50c..590bc9f5d0be 100644 --- a/drivers/staging/greybus/uart.c +++ b/drivers/staging/greybus/uart.c @@ -618,9 +618,11 @@ static int gb_uart_connection_init(struct gb_connection *connection) if (minor == -ENOSPC) { dev_err(&connection->dev, "no more free minor numbers\n"); - return -ENODEV; + retval = -ENODEV; + goto error_version; } - return minor; + retval = minor; + goto error_version; } gb_tty->minor = minor; -- 2.39.5