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

Commit df6b110

Browse files
gregkhKevinAlavik
authored andcommitted
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 <[email protected]>
1 parent ca110b0 commit df6b110

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: drivers/staging/greybus/connection.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ struct gb_connection *gb_connection_create(struct gb_interface *interface,
169169
}
170170

171171
hd = interface->gmod->hd;
172-
connection->hd = hd; /* XXX refcount? */
172+
connection->hd = hd;
173173
if (!gb_connection_hd_cport_id_alloc(connection)) {
174-
/* kref_put(connection->hd); */
175174
gb_protocol_put(connection);
176175
kfree(connection);
177176
return NULL;
@@ -193,9 +192,8 @@ struct gb_connection *gb_connection_create(struct gb_interface *interface,
193192
retval = device_add(&connection->dev);
194193
if (retval) {
195194
gb_connection_hd_cport_id_free(connection);
196-
/* kref_put(connection->hd); */
197195
gb_protocol_put(connection);
198-
kfree(connection);
196+
put_device(&connection->dev);
199197
return NULL;
200198
}
201199

0 commit comments

Comments
 (0)