From 4b640bb1357a3eed16a04b23167dc3de4294dcd9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 29 Oct 2014 09:57:08 +0800 Subject: [PATCH] greybus: connection: fix up error patch logic in gb_connection_create() Once you have called device_initialize() you have to call put_device() on the structure to clean it up on an error path, otherwise you will leak memory. Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/connection.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index dac47b3..c4b6505 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -169,9 +169,8 @@ struct gb_connection *gb_connection_create(struct gb_interface *interface, } hd = interface->gmod->hd; - connection->hd = hd; /* XXX refcount? */ + connection->hd = hd; if (!gb_connection_hd_cport_id_alloc(connection)) { - /* kref_put(connection->hd); */ gb_protocol_put(connection); kfree(connection); return NULL; @@ -193,9 +192,8 @@ struct gb_connection *gb_connection_create(struct gb_interface *interface, retval = device_add(&connection->dev); if (retval) { gb_connection_hd_cport_id_free(connection); - /* kref_put(connection->hd); */ gb_protocol_put(connection); - kfree(connection); + put_device(&connection->dev); return NULL; } -- 2.7.4