* [PATCH RESEND] x86/pmem: fix platform-device leak in error path
@ 2022-06-20 14:07 Johan Hovold
2022-06-20 16:11 ` [tip: x86/misc] x86/pmem: Fix " tip-bot2 for Johan Hovold
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2022-06-20 14:07 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen
Cc: x86, H. Peter Anvin, linux-kernel, Johan Hovold
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>
---
It's been almost four months so resending.
Obviously not an important fix in itself, but this allows for getting
rid of the last two users of platform_device_add() that failed to
release the platform device on errors (and may help prevent new ones
from being added).
Johan
arch/x86/kernel/pmem.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c
index 6b07faaa1579..23154d24b117 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);
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip: x86/misc] x86/pmem: Fix platform-device leak in error path
2022-06-20 14:07 [PATCH RESEND] x86/pmem: fix platform-device leak in error path Johan Hovold
@ 2022-06-20 16:11 ` tip-bot2 for Johan Hovold
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Johan Hovold @ 2022-06-20 16:11 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Johan Hovold, Borislav Petkov, x86, linux-kernel
The following commit has been merged into the x86/misc branch of tip:
Commit-ID: 229e73d46994f15314f58b2d39bf952111d89193
Gitweb: https://git.kernel.org/tip/229e73d46994f15314f58b2d39bf952111d89193
Author: Johan Hovold <johan@kernel.org>
AuthorDate: Mon, 20 Jun 2022 16:07:23 +02:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Mon, 20 Jun 2022 18:01:16 +02:00
x86/pmem: Fix platform-device leak in error path
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
---
arch/x86/kernel/pmem.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c
index 6b07faa..23154d2 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);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-20 16:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-20 14:07 [PATCH RESEND] x86/pmem: fix platform-device leak in error path Johan Hovold
2022-06-20 16:11 ` [tip: x86/misc] x86/pmem: Fix " tip-bot2 for Johan Hovold
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.