]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
greybus: power_supply: fix error path at supplies setup
authorRui Miguel Silva <rui.silva@linaro.org>
Fri, 8 Jan 2016 13:53:45 +0000 (13:53 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 12 Jan 2016 03:18:14 +0000 (19:18 -0800)
If something goes wrong at setup time for the supplies, we need to
release all the resources allocated already.

Call the supplies release function which will handle the correct
teardown of the supplies.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/power_supply.c

index 7d1848b99d9b3ad317183bf4d930976a54039640..28548a2432403aab43cfaa86730563e4ada3a32c 100644 (file)
@@ -731,6 +731,7 @@ static int gb_power_supply_event_recv(u8 type, struct gb_operation *op)
 static int gb_power_supply_connection_init(struct gb_connection *connection)
 {
        struct gb_power_supplies *supplies;
+       int ret;
 
        supplies = kzalloc(sizeof(*supplies), GFP_KERNEL);
        if (!supplies)
@@ -741,7 +742,11 @@ static int gb_power_supply_connection_init(struct gb_connection *connection)
 
        mutex_init(&supplies->supplies_lock);
 
-       return gb_power_supplies_setup(supplies);
+       ret = gb_power_supplies_setup(supplies);
+       if (ret < 0)
+               _gb_power_supplies_release(supplies);
+
+       return ret;
 }
 
 static void gb_power_supply_connection_exit(struct gb_connection *connection)