gpio: mockup: fix NULL pointer dereference when removing debugfs
authorBartosz Golaszewski <brgl@bgdev.pl>
Tue, 20 Sep 2022 07:18:41 +0000 (09:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:11:43 +0000 (11:11 +0200)
commit18352095a0d581f6aeb1e9fc9d68cc0152cd64b4
tree2feada3cf7f67efc845d8a0b034064354dbddaa0
parent2279e977405bd59095468f5f8b7676eced606e72
gpio: mockup: fix NULL pointer dereference when removing debugfs

commit b7df41a6f79dfb18ba2203f8c5f0e9c0b9b57f68 upstream.

We now remove the device's debugfs entries when unbinding the driver.
This now causes a NULL-pointer dereference on module exit because the
platform devices are unregistered *after* the global debugfs directory
has been recursively removed. Fix it by unregistering the devices first.

Fixes: 303e6da99429 ("gpio: mockup: remove gpio debugfs when remove device")
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpio/gpio-mockup.c