summaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
authorGreg KH <gregkh@linuxfoundation.org>2019-05-08 12:40:42 +0200
committerTony Luck <tony.luck@intel.com>2019-06-20 11:44:36 -0700
commit7adc05d2dc3af95e4e1534841d58f736262142cd (patch)
tree9d4c047fda186cd7d7dcbc665243f3348c2c7212 /drivers/edac
parent585fb3d93d32dbe89e718b85009f9c322cc554cd (diff)
downloadlinux-7adc05d2dc3af95e4e1534841d58f736262142cd.tar.bz2
EDAC/sysfs: Drop device references properly
Do put_device() if device_add() fails. [ bp: do device_del() for the successfully created devices in edac_create_csrow_objects(), on the unwind path. ] Signed-off-by: Greg KH <gregkh@linuxfoundation.org> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20190427214925.GE16338@kroah.com
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/edac_mc_sysfs.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 9b7d396f26e9..7c01e1cc030c 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -449,7 +449,8 @@ error:
csrow = mci->csrows[i];
if (!nr_pages_per_csrow(csrow))
continue;
- put_device(&mci->csrows[i]->dev);
+
+ device_del(&mci->csrows[i]->dev);
}
return err;
@@ -651,9 +652,11 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci,
dev_set_drvdata(&dimm->dev, dimm);
pm_runtime_forbid(&mci->dev);
- err = device_add(&dimm->dev);
+ err = device_add(&dimm->dev);
+ if (err)
+ put_device(&dimm->dev);
- edac_dbg(0, "creating rank/dimm device %s\n", dev_name(&dimm->dev));
+ edac_dbg(0, "created rank/dimm device %s\n", dev_name(&dimm->dev));
return err;
}
@@ -934,6 +937,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci,
err = device_add(&mci->dev);
if (err < 0) {
edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));
+ put_device(&mci->dev);
goto out;
}