greybus: power_supply: free supplies at release
authorRui Miguel Silva <rui.silva@linaro.org>
Fri, 8 Jan 2016 13:53:44 +0000 (13:53 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 12 Jan 2016 03:18:14 +0000 (19:18 -0800)
After freeing each individual power_supply, free the top controller, if
not it will leak memory at each module insert/remove.

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 764d2f640164dca73c9eb0b860107d63aef2f3bd..7d1848b99d9b3ad317183bf4d930976a54039640 100644 (file)
@@ -579,6 +579,7 @@ static void _gb_power_supplies_release(struct gb_power_supplies *supplies)
        for (i = 0; i < supplies->supplies_count; i++)
                _gb_power_supply_release(&supplies->supply[i]);
        mutex_unlock(&supplies->supplies_lock);
+       kfree(supplies);
 }
 
 static int gb_power_supplies_get_count(struct gb_power_supplies *supplies)