greybus: power_supply: fix lock imbalance in init error path
authorJohan Hovold <johan@hovoldconsulting.com>
Thu, 7 Jan 2016 11:28:29 +0000 (12:28 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 12 Jan 2016 03:16:12 +0000 (19:16 -0800)
Make sure to release the supplies_lock before returning on errors in
gb_power_supplies_setup().

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

index 4a7381650bb7321a801f6ad8ebbe147d76e2d37a..1f3884bccf97c53ddbe2c713e3845f1add0f93c0 100644 (file)
@@ -644,8 +644,10 @@ static int gb_power_supplies_setup(struct gb_power_supplies *supplies)
                                     sizeof(struct gb_power_supply),
                                     GFP_KERNEL);
 
-       if (!supplies->supply)
-               return -ENOMEM;
+       if (!supplies->supply) {
+               ret = -ENOMEM;
+               goto out;
+       }
 
        for (i = 0; i < supplies->supplies_count; i++) {
                ret = gb_power_supply_config(supplies, i);