aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/power_supply.c
diff options
context:
space:
mode:
authorRui Miguel Silva <rui.silva@linaro.org>2016-01-08 13:53:45 +0000
committerGreg Kroah-Hartman <gregkh@google.com>2016-01-11 19:18:14 -0800
commitd9eafd58e3e365d71cd7d477a1c5675db1931027 (patch)
tree68c350605d674c7ada0b7e87c917037a4592b8ed /drivers/staging/greybus/power_supply.c
parentgreybus: power_supply: free supplies at release (diff)
downloadlinux-dev-d9eafd58e3e365d71cd7d477a1c5675db1931027.tar.xz
linux-dev-d9eafd58e3e365d71cd7d477a1c5675db1931027.zip
greybus: power_supply: fix error path at supplies setup
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>
Diffstat (limited to 'drivers/staging/greybus/power_supply.c')
-rw-r--r--drivers/staging/greybus/power_supply.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c
index 7d1848b99d9b..28548a243240 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -731,6 +731,7 @@ out_unlock:
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)