]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: connection: fix up error patch logic in gb_connection_create()
authorGreg Kroah-Hartman <greg@kroah.com>
Wed, 29 Oct 2014 01:57:08 +0000 (09:57 +0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 29 Oct 2014 01:57:08 +0000 (09:57 +0800)
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>
drivers/staging/greybus/connection.c

index dac47b33855f257395b4a1a6e8272380ac883b94..c4b650522ac2c32006e934138c5fc0dea02b8e9b 100644 (file)
@@ -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;
        }