diff options
author | Lans Zhang <jia.zhang@windriver.com> | 2012-12-24 08:01:34 -0500 |
---|---|---|
committer | Borislav Petkov <bpetkov@suse.de> | 2013-01-07 11:43:00 -0500 |
commit | 44d22e2404b3ce93a314654962d31acc8afcdd62 (patch) | |
tree | f3d254d755d99d723caa4caff200455d19f52b27 /drivers/edac | |
parent | 5445166384755adc39c772acccca87ad5747be52 (diff) |
EDAC: Cleanup device deregistering path
Use device_unregister to replace put_device + device_del for
cleanup, and fix the potential use after free.
Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
Signed-off-by: Borislav Petkov <bp@alien8.de>
Diffstat (limited to 'drivers/edac')
-rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index a3b0119ecb00..0ca1ca71157f 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -472,8 +472,7 @@ static void edac_delete_csrow_objects(struct mem_ctl_info *mci) | |||
472 | device_remove_file(&csrow->dev, | 472 | device_remove_file(&csrow->dev, |
473 | dynamic_csrow_ce_count_attr[chan]); | 473 | dynamic_csrow_ce_count_attr[chan]); |
474 | } | 474 | } |
475 | put_device(&mci->csrows[i]->dev); | 475 | device_unregister(&mci->csrows[i]->dev); |
476 | device_del(&mci->csrows[i]->dev); | ||
477 | } | 476 | } |
478 | } | 477 | } |
479 | #endif | 478 | #endif |
@@ -1055,11 +1054,9 @@ fail: | |||
1055 | struct dimm_info *dimm = mci->dimms[i]; | 1054 | struct dimm_info *dimm = mci->dimms[i]; |
1056 | if (dimm->nr_pages == 0) | 1055 | if (dimm->nr_pages == 0) |
1057 | continue; | 1056 | continue; |
1058 | put_device(&dimm->dev); | 1057 | device_unregister(&dimm->dev); |
1059 | device_del(&dimm->dev); | ||
1060 | } | 1058 | } |
1061 | put_device(&mci->dev); | 1059 | device_unregister(&mci->dev); |
1062 | device_del(&mci->dev); | ||
1063 | bus_unregister(&mci->bus); | 1060 | bus_unregister(&mci->bus); |
1064 | kfree(mci->bus.name); | 1061 | kfree(mci->bus.name); |
1065 | return err; | 1062 | return err; |
@@ -1086,16 +1083,14 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1086 | if (dimm->nr_pages == 0) | 1083 | if (dimm->nr_pages == 0) |
1087 | continue; | 1084 | continue; |
1088 | edac_dbg(0, "removing device %s\n", dev_name(&dimm->dev)); | 1085 | edac_dbg(0, "removing device %s\n", dev_name(&dimm->dev)); |
1089 | put_device(&dimm->dev); | 1086 | device_unregister(&dimm->dev); |
1090 | device_del(&dimm->dev); | ||
1091 | } | 1087 | } |
1092 | } | 1088 | } |
1093 | 1089 | ||
1094 | void edac_unregister_sysfs(struct mem_ctl_info *mci) | 1090 | void edac_unregister_sysfs(struct mem_ctl_info *mci) |
1095 | { | 1091 | { |
1096 | edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev)); | 1092 | edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev)); |
1097 | put_device(&mci->dev); | 1093 | device_unregister(&mci->dev); |
1098 | device_del(&mci->dev); | ||
1099 | bus_unregister(&mci->bus); | 1094 | bus_unregister(&mci->bus); |
1100 | kfree(mci->bus.name); | 1095 | kfree(mci->bus.name); |
1101 | } | 1096 | } |
@@ -1159,7 +1154,6 @@ int __init edac_mc_sysfs_init(void) | |||
1159 | 1154 | ||
1160 | void __exit edac_mc_sysfs_exit(void) | 1155 | void __exit edac_mc_sysfs_exit(void) |
1161 | { | 1156 | { |
1162 | device_del(mci_pdev); | 1157 | device_unregister(mci_pdev); |
1163 | put_device(mci_pdev); | ||
1164 | edac_put_sysfs_subsys(); | 1158 | edac_put_sysfs_subsys(); |
1165 | } | 1159 | } |