Skip to content

Commit 229e73d

Browse files
jhovoldsuryasaimadhu
authored andcommitted
x86/pmem: Fix platform-device leak in error path
Make sure to free the platform device in the unlikely event that registration fails. Fixes: 7a67832 ("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
1 parent a111daf commit 229e73d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

arch/x86/kernel/pmem.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ static __init int register_e820_pmem(void)
2727
* simply here to trigger the module to load on demand.
2828
*/
2929
pdev = platform_device_alloc("e820_pmem", -1);
30-
return platform_device_add(pdev);
30+
31+
rc = platform_device_add(pdev);
32+
if (rc)
33+
platform_device_put(pdev);
34+
35+
return rc;
3136
}
3237
device_initcall(register_e820_pmem);

0 commit comments

Comments
 (0)