]> asedeno.scripts.mit.edu Git - linux.git/commit
power: supply: ds2782: fix possible use-after-free on remove
authorSven Van Asbroeck <thesven73@gmail.com>
Tue, 12 Feb 2019 16:21:49 +0000 (11:21 -0500)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 12 Feb 2019 22:27:16 +0000 (23:27 +0100)
commit74f0aaba7c7161f2f777015f6c2e6d8c2c44aa8f
treed71595d6627201036a1825bd4cee72dcd3724701
parentf83a6ece6997fe64ce9b02e8169c3fb43c68ea55
power: supply: ds2782: fix possible use-after-free on remove

In remove(), use cancel_delayed_work_sync() to cancel the
delayed work. Otherwise there's a chance that this work
will continue to run until after the device has been removed.

While we're here, fix the deallocation order in remove(),
to correspond to the inverse of the probe() allocation
order. This guarantees that any remaining work can run
to completion with all driver structures still intact.

This issue was detected with the help of Coccinelle.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/ds2782_battery.c