aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/uart.c
diff options
context:
space:
mode:
authorPhong Tran <tranmanphong@gmail.com>2015-06-10 21:03:17 +0700
committerGreg Kroah-Hartman <gregkh@google.com>2015-06-11 15:57:44 -0700
commit55a8e3550364a35bc5d40fa0e445049a5df62627 (patch)
treec8c505e762ed709b600aba23d41745c018d7291c /drivers/staging/greybus/uart.c
parentgreybus: remove __init from .h files (diff)
downloadlinux-dev-55a8e3550364a35bc5d40fa0e445049a5df62627.tar.xz
linux-dev-55a8e3550364a35bc5d40fa0e445049a5df62627.zip
greybus: uart: fix the clean up while uart initiates connection unsucessfully
There is lack of unregister and free the tty driver. This patch fixes it. Signed-off-by: Phong Tran <tranmanphong@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/uart.c')
-rw-r--r--drivers/staging/greybus/uart.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7e94632a581b..20928702a5b2 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -586,20 +586,22 @@ static int gb_uart_connection_init(struct gb_connection *connection)
}
gb_tty = kzalloc(sizeof(*gb_tty), GFP_KERNEL);
- if (!gb_tty)
- return -ENOMEM;
+ if (!gb_tty) {
+ retval = -ENOMEM;
+ goto error_alloc;
+ }
gb_tty->buffer_payload_max =
gb_operation_get_payload_size_max(connection);
if (!gb_tty->buffer_payload_max) {
- kfree(gb_tty);
- return -EINVAL;
+ retval = -EINVAL;
+ goto error_payload;
}
gb_tty->buffer = kzalloc(gb_tty->buffer_payload_max, GFP_KERNEL);
if (!gb_tty->buffer) {
- kfree(gb_tty);
- return -ENOMEM;
+ retval = -ENOMEM;
+ goto error_payload;
}
gb_tty->connection = connection;
@@ -654,7 +656,11 @@ error:
error_version:
connection->private = NULL;
kfree(gb_tty->buffer);
+error_payload:
kfree(gb_tty);
+error_alloc:
+ if (atomic_dec_return(&reference_count) == 0)
+ gb_tty_exit();
return retval;
}