projects
/
platform
/
kernel
/
linux-rpi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f6502ce
)
EDAC/sysfs: Fix memory leak when creating a csrow object
author
Pan Bian
<bianpan2016@163.com>
Thu, 18 Apr 2019 02:27:18 +0000
(10:27 +0800)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:14:09 +0000
(09:14 +0200)
[ Upstream commit
585fb3d93d32dbe89e718b85009f9c322cc554cd
]
In edac_create_csrow_object(), the reference to the object is not
released when adding the device to the device hierarchy fails
(device_add()). This may result in a memory leak.
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: James Morse <james.morse@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link:
https://lkml.kernel.org/r/1555554438-103953-1-git-send-email-bianpan2016@163.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/edac/edac_mc_sysfs.c
patch
|
blob
|
history
diff --git
a/drivers/edac/edac_mc_sysfs.c
b/drivers/edac/edac_mc_sysfs.c
index
20374b8
..
e50610b
100644
(file)
--- a/
drivers/edac/edac_mc_sysfs.c
+++ b/
drivers/edac/edac_mc_sysfs.c
@@
-404,6
+404,8
@@
static inline int nr_pages_per_csrow(struct csrow_info *csrow)
static int edac_create_csrow_object(struct mem_ctl_info *mci,
struct csrow_info *csrow, int index)
{
+ int err;
+
csrow->dev.type = &csrow_attr_type;
csrow->dev.bus = mci->bus;
csrow->dev.groups = csrow_dev_groups;
@@
-416,7
+418,11
@@
static int edac_create_csrow_object(struct mem_ctl_info *mci,
edac_dbg(0, "creating (virtual) csrow node %s\n",
dev_name(&csrow->dev));
- return device_add(&csrow->dev);
+ err = device_add(&csrow->dev);
+ if (err)
+ put_device(&csrow->dev);
+
+ return err;
}
/* Create a CSROW object under specifed edac_mc_device */