提交 7ec11a43 编写于 作者: J Johan Hovold 提交者: sanglipeng

efi: fix NULL-deref in init error path

stable inclusion
from stable-v5.10.164
commit 4ca71bc0e1995d15486cd7b60845602a28399cb5
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7T7G4

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

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

[ Upstream commit 703c13fe ]

In cases where runtime services are not supported or have been disabled,
the runtime services workqueue will never have been allocated.

Do not try to destroy the workqueue unconditionally in the unlikely
event that EFI initialisation fails to avoid dereferencing a NULL
pointer.

Fixes: 98086df8 ("efi: add missed destroy_workqueue when efisubsys_init fails")
Cc: stable@vger.kernel.org
Cc: Li Heng <liheng40@huawei.com>
Signed-off-by: NJohan Hovold <johan+linaro@kernel.org>
Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 acad0639
...@@ -386,8 +386,8 @@ static int __init efisubsys_init(void) ...@@ -386,8 +386,8 @@ static int __init efisubsys_init(void)
efi_kobj = kobject_create_and_add("efi", firmware_kobj); efi_kobj = kobject_create_and_add("efi", firmware_kobj);
if (!efi_kobj) { if (!efi_kobj) {
pr_err("efi: Firmware registration failed.\n"); pr_err("efi: Firmware registration failed.\n");
destroy_workqueue(efi_rts_wq); error = -ENOMEM;
return -ENOMEM; goto err_destroy_wq;
} }
if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE | if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE |
...@@ -430,7 +430,10 @@ static int __init efisubsys_init(void) ...@@ -430,7 +430,10 @@ static int __init efisubsys_init(void)
generic_ops_unregister(); generic_ops_unregister();
err_put: err_put:
kobject_put(efi_kobj); kobject_put(efi_kobj);
destroy_workqueue(efi_rts_wq); err_destroy_wq:
if (efi_rts_wq)
destroy_workqueue(efi_rts_wq);
return error; return error;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册