* [PATCH] edac: Fix reference count leak in edac_pci_main_kobj_setup.
@ 2020-05-28 20:22 wu000273
2020-06-17 13:56 ` Borislav Petkov
0 siblings, 1 reply; 2+ messages in thread
From: wu000273 @ 2020-05-28 20:22 UTC (permalink / raw)
To: kjlu
Cc: wu000273, Borislav Petkov, Mauro Carvalho Chehab, Tony Luck,
James Morse, Robert Richter, Greg Kroah-Hartman, Doug Thompson,
linux-edac, linux-kernel
From: Qiushi Wu <wu000273@umn.edu>
kobject_init_and_add() should be handled when it return an error,
because kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object. Previous
commit "b8eb718348b8" fixed a similar problem. Thus replace calling
kfree() by calling kobject_put().
Fixes: b2ed215a3338 ("Kobject: change drivers/edac to use kobject_init_and_add")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
drivers/edac/edac_pci_sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 72c9eb9fdffb..53042af7262e 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -386,7 +386,7 @@ static int edac_pci_main_kobj_setup(void)
/* Error unwind statck */
kobject_init_and_add_fail:
- kfree(edac_pci_top_main_kobj);
+ kobject_put(edac_pci_top_main_kobj);
kzalloc_fail:
module_put(THIS_MODULE);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] edac: Fix reference count leak in edac_pci_main_kobj_setup.
2020-05-28 20:22 [PATCH] edac: Fix reference count leak in edac_pci_main_kobj_setup wu000273
@ 2020-06-17 13:56 ` Borislav Petkov
0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2020-06-17 13:56 UTC (permalink / raw)
To: wu000273
Cc: kjlu, Mauro Carvalho Chehab, Tony Luck, James Morse,
Robert Richter, Greg Kroah-Hartman, Doug Thompson, linux-edac,
linux-kernel
On Thu, May 28, 2020 at 03:22:37PM -0500, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
>
> kobject_init_and_add() should be handled when it return an error,
> because kobject_init_and_add() takes reference even when it fails.
> If this function returns an error, kobject_put() must be called to
> properly clean up the memory associated with the object. Previous
> commit "b8eb718348b8" fixed a similar problem. Thus replace calling
> kfree() by calling kobject_put().
>
> Fixes: b2ed215a3338 ("Kobject: change drivers/edac to use kobject_init_and_add")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
> drivers/edac/edac_pci_sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
> index 72c9eb9fdffb..53042af7262e 100644
> --- a/drivers/edac/edac_pci_sysfs.c
> +++ b/drivers/edac/edac_pci_sysfs.c
> @@ -386,7 +386,7 @@ static int edac_pci_main_kobj_setup(void)
>
> /* Error unwind statck */
> kobject_init_and_add_fail:
> - kfree(edac_pci_top_main_kobj);
> + kobject_put(edac_pci_top_main_kobj);
>
> kzalloc_fail:
> module_put(THIS_MODULE);
> --
This and
https://lkml.kernel.org/r/20200528203526.20908-1-wu000273@umn.edu
merged into a single patch and applied.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-17 13:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 20:22 [PATCH] edac: Fix reference count leak in edac_pci_main_kobj_setup wu000273
2020-06-17 13:56 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).