From 7ccac20d59ca45a2efea93a24a99d57022ff8911 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva Date: Fri, 8 Jan 2016 13:53:42 +0000 Subject: [PATCH] greybus: power_supply: do not release failed supply alloc If allocation of memory for each supply fail, we should get out of release any individual supply. Signed-off-by: Rui Miguel Silva Reported-by: Johan Hovold Reviewed-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/power_supply.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c index 1f3884bccf97..1ce57f6333da 100644 --- a/drivers/staging/greybus/power_supply.c +++ b/drivers/staging/greybus/power_supply.c @@ -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]); -- 2.20.1