aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/fmc/fmc-chardev.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/fmc/fmc-chardev.c b/drivers/fmc/fmc-chardev.c
index b0710393ede6..cc031db2d2a3 100644
--- a/drivers/fmc/fmc-chardev.c
+++ b/drivers/fmc/fmc-chardev.c
@@ -136,6 +136,8 @@ static int fc_probe(struct fmc_device *fmc)
136 136
137 /* Create a char device: we want to create it anew */ 137 /* Create a char device: we want to create it anew */
138 fc = kzalloc(sizeof(*fc), GFP_KERNEL); 138 fc = kzalloc(sizeof(*fc), GFP_KERNEL);
139 if (!fc)
140 return -ENOMEM;
139 fc->fmc = fmc; 141 fc->fmc = fmc;
140 fc->misc.minor = MISC_DYNAMIC_MINOR; 142 fc->misc.minor = MISC_DYNAMIC_MINOR;
141 fc->misc.fops = &fc_fops; 143 fc->misc.fops = &fc_fops;
@@ -143,15 +145,18 @@ static int fc_probe(struct fmc_device *fmc)
143 145
144 spin_lock(&fc_lock); 146 spin_lock(&fc_lock);
145 ret = misc_register(&fc->misc); 147 ret = misc_register(&fc->misc);
146 if (ret < 0) { 148 if (ret < 0)
147 kfree(fc->misc.name); 149 goto err_unlock;
148 kfree(fc); 150 list_add(&fc->list, &fc_devices);
149 } else {
150 list_add(&fc->list, &fc_devices);
151 }
152 spin_unlock(&fc_lock); 151 spin_unlock(&fc_lock);
153 dev_info(&fc->fmc->dev, "Created misc device \"%s\"\n", 152 dev_info(&fc->fmc->dev, "Created misc device \"%s\"\n",
154 fc->misc.name); 153 fc->misc.name);
154 return 0;
155
156err_unlock:
157 spin_unlock(&fc_lock);
158 kfree(fc->misc.name);
159 kfree(fc);
155 return ret; 160 return ret;
156} 161}
157 162