summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2022-06-20 16:07:23 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-25 11:11:15 +0200
commit14498162de9077f24a0e4d605cd1d5795b707073 (patch)
tree63b49ed628efc528354f5cd83dc0d152d1f323a6 /arch
parent62d719d31ec667276d7375b64542b080cf187797 (diff)
downloadlinux-rt-14498162de9077f24a0e4d605cd1d5795b707073.tar.gz
x86/pmem: Fix platform-device leak in error path
[ Upstream commit 229e73d46994f15314f58b2d39bf952111d89193 ] Make sure to free the platform device in the unlikely event that registration fails. Fixes: 7a67832c7e44 ("libnvdimm, e820: make CONFIG_X86_PMEM_LEGACY a tristate option") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/20220620140723.9810-1-johan@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/pmem.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c
index 3fe690067802..ada7c077ec2f 100644
--- a/arch/x86/kernel/pmem.c
+++ b/arch/x86/kernel/pmem.c
@@ -27,6 +27,11 @@ static __init int register_e820_pmem(void)
* simply here to trigger the module to load on demand.
*/
pdev = platform_device_alloc("e820_pmem", -1);
- return platform_device_add(pdev);
+
+ rc = platform_device_add(pdev);
+ if (rc)
+ platform_device_put(pdev);
+
+ return rc;
}
device_initcall(register_e820_pmem);