aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
authorDenis Kirjanov <kirjanov@gmail.com>2012-10-25 11:42:58 -0400
committerBorislav Petkov <bp@alien8.de>2012-11-28 05:56:52 -0500
commit2d56b109e3a50cf316e60f07541bbeb1d8fe251a (patch)
tree097069078a1e669ec9fe4b5fa8b917e91daa4ee1 /drivers/edac
parentd5c6770d4cb27bc33aa433cf8fb848ad9af6644b (diff)
EDAC: Handle error path in edac_mc_sysfs_init() properly
Make sure proper deregistration happens on all error paths in edac_mc_sysfs_init. Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> [ Boris: cleanup and concretize commit message ] Signed-off-by: Borislav Petkov <bp@alien8.de>
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/edac_mc_sysfs.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 52813b8b0f5f..de2df92f9c77 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -1126,10 +1126,15 @@ int __init edac_mc_sysfs_init(void)
1126 edac_subsys = edac_get_sysfs_subsys(); 1126 edac_subsys = edac_get_sysfs_subsys();
1127 if (edac_subsys == NULL) { 1127 if (edac_subsys == NULL) {
1128 edac_dbg(1, "no edac_subsys\n"); 1128 edac_dbg(1, "no edac_subsys\n");
1129 return -EINVAL; 1129 err = -EINVAL;
1130 goto out;
1130 } 1131 }
1131 1132
1132 mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL); 1133 mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);
1134 if (!mci_pdev) {
1135 err = -ENOMEM;
1136 goto out_put_sysfs;
1137 }
1133 1138
1134 mci_pdev->bus = edac_subsys; 1139 mci_pdev->bus = edac_subsys;
1135 mci_pdev->type = &mc_attr_type; 1140 mci_pdev->type = &mc_attr_type;
@@ -1138,11 +1143,18 @@ int __init edac_mc_sysfs_init(void)
1138 1143
1139 err = device_add(mci_pdev); 1144 err = device_add(mci_pdev);
1140 if (err < 0) 1145 if (err < 0)
1141 return err; 1146 goto out_dev_free;
1142 1147
1143 edac_dbg(0, "device %s created\n", dev_name(mci_pdev)); 1148 edac_dbg(0, "device %s created\n", dev_name(mci_pdev));
1144 1149
1145 return 0; 1150 return 0;
1151
1152 out_dev_free:
1153 kfree(mci_pdev);
1154 out_put_sysfs:
1155 edac_put_sysfs_subsys();
1156 out:
1157 return err;
1146} 1158}
1147 1159
1148void __exit edac_mc_sysfs_exit(void) 1160void __exit edac_mc_sysfs_exit(void)
@@ -1150,4 +1162,5 @@ void __exit edac_mc_sysfs_exit(void)
1150 put_device(mci_pdev); 1162 put_device(mci_pdev);
1151 device_del(mci_pdev); 1163 device_del(mci_pdev);
1152 edac_put_sysfs_subsys(); 1164 edac_put_sysfs_subsys();
1165 kfree(mci_pdev);
1153} 1166}