[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200528202238.18078-1-wu000273@umn.edu>
Date: Thu, 28 May 2020 15:22:37 -0500
From: wu000273@....edu
To: kjlu@....edu
Cc: wu000273@....edu, Borislav Petkov <bp@...en8.de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Tony Luck <tony.luck@...el.com>,
James Morse <james.morse@....com>,
Robert Richter <rrichter@...vell.com>,
Greg Kroah-Hartman <gregkh@...e.de>,
Doug Thompson <dougthompson@...ssion.com>,
linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] edac: Fix reference count leak in edac_pci_main_kobj_setup.
From: Qiushi Wu <wu000273@....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@....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
Powered by blists - more mailing lists