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>
}
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;
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;
}