提交 20533fcf 编写于 作者: B Bartosz Golaszewski 提交者: Jialin Zhang

gpio: mockup: fix NULL pointer dereference when removing debugfs

stable inclusion
from stable-v5.10.146
commit bdea98b98f844bd8a983ca880893e509a8b4162f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0VX

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bdea98b98f844bd8a983ca880893e509a8b4162f

--------------------------------

commit b7df41a6 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: 303e6da9 ("gpio: mockup: remove gpio debugfs when remove device")
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 0a15b810
...@@ -604,9 +604,9 @@ static int __init gpio_mockup_init(void) ...@@ -604,9 +604,9 @@ static int __init gpio_mockup_init(void)
static void __exit gpio_mockup_exit(void) static void __exit gpio_mockup_exit(void)
{ {
gpio_mockup_unregister_pdevs();
debugfs_remove_recursive(gpio_mockup_dbg_dir); debugfs_remove_recursive(gpio_mockup_dbg_dir);
platform_driver_unregister(&gpio_mockup_driver); platform_driver_unregister(&gpio_mockup_driver);
gpio_mockup_unregister_pdevs();
} }
module_init(gpio_mockup_init); module_init(gpio_mockup_init);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册