greybus: power_supply: fix use after free of power supply
authorRui Miguel Silva <rui.silva@linaro.org>
Fri, 8 Jan 2016 13:53:47 +0000 (13:53 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 12 Jan 2016 03:18:14 +0000 (19:18 -0800)
commitaccad1ba7d62543ab3bcf08813726ea87d237bb6
treec5fe2f6d38138e1b1118e1b6982a541181325bdf
parentf921fb139bd5ee008ec993c76b8a89a535fd11e9
greybus: power_supply: fix use after free of power supply

Individual power supply were being freed and checked using the wrong
pointers and at the wrong place, which would make several issues, like
used after free and so on.
Fix it by freeing all allocated memory after release individual power
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