leds: wm831x-status: fix use-after-free on unbind
authorJohan Hovold <johan@kernel.org>
Mon, 1 Jun 2020 13:39:49 +0000 (15:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Aug 2020 13:35:33 +0000 (15:35 +0200)
commita6da8ea3302807ea1ff914e4508aa383bca47e74
treebdfffe14d98ac1e1109d24dfd7b1e2521db45679
parent36a8b2f49235e63ab3f901fe12e1b6732f075c2e
leds: wm831x-status: fix use-after-free on unbind

commit 47a459ecc800a17109d0c496a4e21e478806ee40 upstream.

Several MFD child drivers register their class devices directly under
the parent device. This means you cannot blindly do devres conversions
so that deregistration ends up being tied to the parent device,
something which leads to use-after-free on driver unbind when the class
device is released while still being registered.

Fixes: 8d3b6a4001ce ("leds: wm831x-status: Use devm_led_classdev_register")
Cc: stable <stable@vger.kernel.org> # 4.6
Cc: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/leds/leds-wm831x-status.c