greybus: power_supply: do not release failed supply alloc
authorRui Miguel Silva <rui.silva@linaro.org>
Fri, 8 Jan 2016 13:53:42 +0000 (13:53 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 12 Jan 2016 03:18:14 +0000 (19:18 -0800)
If allocation of memory for each supply fail, we should get out of
release any individual supply.

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 1f3884bccf97c53ddbe2c713e3845f1add0f93c0..1ce57f6333dad44f51a57e2d20bcb37dea3135ba 100644 (file)
@@ -569,6 +569,9 @@ static void _gb_power_supplies_release(struct gb_power_supplies *supplies)
 {
        int i;
 
+       if (!supplies->supply)
+               return;
+
        mutex_lock(&supplies->supplies_lock);
        for (i = 0; i < supplies->supplies_count; i++)
                _gb_power_supply_release(&supplies->supply[i]);