Commit 4b640bb1 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 4ccb6b7a
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment