mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 21:57:43 +00:00
x86/pmem: Fix platform-device leak in error path
[ Upstream commit229e73d469
] Make sure to free the platform device in the unlikely event that registration fails. Fixes:7a67832c7e
("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>
This commit is contained in:
parent
5afe042c88
commit
0b7f674c12
1 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue