OSDN Git Service

greybus: uart: Fix the memory leak in connection init
authorPhong Tran <tranmanphong@gmail.com>
Mon, 1 Jun 2015 15:19:45 +0000 (22:19 +0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 4 Jun 2015 05:04:18 +0000 (14:04 +0900)
If alloc minor is error, gb_tty should free.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/uart.c

index 47de969..590bc9f 100644 (file)
@@ -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;