diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2014-11-13 18:14:37 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <greg@kroah.com> | 2014-11-14 13:17:55 -0800 |
commit | 0a68a16b914472aa3c9dbac81df501b9c8dffb86 (patch) | |
tree | a22393d12c42c2891b3c5d188fcfb1278095aebd /drivers/staging/greybus/module.c | |
parent | 132d03ea8989949ed40d52ea6bd4c5aaa083381b (diff) | |
download | linux-0a68a16b914472aa3c9dbac81df501b9c8dffb86.tar.gz linux-0a68a16b914472aa3c9dbac81df501b9c8dffb86.tar.bz2 linux-0a68a16b914472aa3c9dbac81df501b9c8dffb86.zip |
greybus: module: free resources properly on failures
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/module.c')
-rw-r--r-- | drivers/staging/greybus/module.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index f5d7dc84c1d1..8cbe65b0c01a 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -85,10 +85,6 @@ struct gb_module *gb_module_create(struct greybus_host_device *hd, u8 module_id) gmod->module_id = module_id; INIT_LIST_HEAD(&gmod->interfaces); - spin_lock_irq(&gb_modules_lock); - list_add_tail(&gmod->links, &hd->modules); - spin_unlock_irq(&gb_modules_lock); - gmod->dev.parent = hd->parent; gmod->dev.bus = &greybus_bus_type; gmod->dev.type = &greybus_module_type; @@ -102,9 +98,14 @@ struct gb_module *gb_module_create(struct greybus_host_device *hd, u8 module_id) pr_err("failed to add module device for id 0x%02hhx\n", module_id); put_device(&gmod->dev); + kfree(gmod); return NULL; } + spin_lock_irq(&gb_modules_lock); + list_add_tail(&gmod->links, &hd->modules); + spin_unlock_irq(&gb_modules_lock); + return gmod; } |