Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
greybus: connection: fix up error patch logic in gb_connection_create()
Browse files Browse the repository at this point in the history
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 <greg@kroah.com>
  • Loading branch information
gregkh authored and KevinAlavik committed Sep 14, 2023
1 parent ca110b0 commit df6b110
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/staging/greybus/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit df6b110

Please sign in to comment.