[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20200528203526.20908-1-wu000273@umn.edu>
Date: Thu, 28 May 2020 15:35:26 -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>,
Doug Thompson <dougthompson@...ssion.com>,
Greg Kroah-Hartman <gregkh@...e.de>,
linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] edac: Fix reference count leak in edac_device_register_sysfs_main_kobj.
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.
Fixes: b2ed215a3338 ("Kobject: change drivers/edac to use kobject_init_and_add")
Signed-off-by: Qiushi Wu <wu000273@....edu>
---
drivers/edac/edac_device_sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 0e7ea3591b78..5e7593753799 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -275,6 +275,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
/* Error exit stack */
err_kobj_reg:
+ kobject_put(&edac_dev->kobj);
module_put(edac_dev->owner);
err_out:
--
2.17.1
Powered by blists - more mailing lists