]> git.karo-electronics.de Git - karo-tx-linux.git/commit
greybus: battery: free struct on error in caller
authorAlex Elder <elder@linaro.org>
Thu, 7 May 2015 18:00:20 +0000 (13:00 -0500)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 7 May 2015 20:55:43 +0000 (22:55 +0200)
commit9ade6d312287fd1729a02e349f5f23483ffc4e1c
tree852f9a1b0f66bd9ee8dd757e0e00c6ef5512b461
parentc13c8bf0cccd6a9daf8ea02919aecaa45c842fc7
greybus: battery: free struct on error in caller

When a battery connection is initialized, a gb_battery structure for
it is allocated in gb_battery_connection_init().  Currently that
function ends by calling init_and_register(); in the event an error
occurs, init_and_register() is responsible for freeing the allocated
gb_battery structure.

Make the code a bit better balanced by having the function that
allocates the structure be responsible for freeing it in case of
error.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/battery.c