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>
kfree(gbpsy->manufacturer);
kfree(gbpsy->props_raw);
kfree(gbpsy->props);
- kfree(gbpsy);
}
static void _gb_power_supply_release(struct gb_power_supply *gbpsy)
{
- if (!gbpsy)
- return;
gbpsy->update_interval = 0;
mutex_lock(&supplies->supplies_lock);
for (i = 0; i < supplies->supplies_count; i++)
_gb_power_supply_release(&supplies->supply[i]);
+ kfree(supplies->supply);
mutex_unlock(&supplies->supplies_lock);
kfree(supplies);
}