Commit d8ec0e9a authored by Johan Hovold's avatar Johan Hovold Committed by Gu Bowen
Browse files

efi: fix NULL-deref in init error path

stable inclusion
from stable-v4.19.320
commit 585a0b2b3ae7903c6abee3087d09c69e955a7794
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IALIAT
CVE: CVE-2022-48879

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



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

[ 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: default avatarJohan Hovold <johan+linaro@kernel.org>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarGu Bowen <gubowen5@huawei.com>
parent 46d28312
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -361,8 +361,8 @@ static int __init efisubsys_init(void)
	efi_kobj = kobject_create_and_add("efi", firmware_kobj);
	if (!efi_kobj) {
		pr_err("efi: Firmware registration failed.\n");
		destroy_workqueue(efi_rts_wq);
		return -ENOMEM;
		error = -ENOMEM;
		goto err_destroy_wq;
	}

	error = generic_ops_register();
@@ -398,7 +398,10 @@ static int __init efisubsys_init(void)
	generic_ops_unregister();
err_put:
	kobject_put(efi_kobj);
err_destroy_wq:
	if (efi_rts_wq)
		destroy_workqueue(efi_rts_wq);

	return error;
}