Commit 71e49380 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: interface: put module->dev on failures

In order to decrement the reference count of module on failures, we must call
put_device(module->dev). This was missing for one of the error cases, fix it.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 0d34be75
...@@ -132,7 +132,7 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd, ...@@ -132,7 +132,7 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd,
intf = kzalloc(sizeof(*intf), GFP_KERNEL); intf = kzalloc(sizeof(*intf), GFP_KERNEL);
if (!intf) if (!intf)
return NULL; goto put_module;
intf->hd = hd; /* XXX refcount? */ intf->hd = hd; /* XXX refcount? */
intf->module = module; intf->module = module;
...@@ -151,10 +151,7 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd, ...@@ -151,10 +151,7 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd,
if (retval) { if (retval) {
pr_err("failed to add module device for id 0x%02hhx\n", pr_err("failed to add module device for id 0x%02hhx\n",
module_id); module_id);
put_device(&intf->dev); goto free_intf;
put_device(&module->dev);
kfree(intf);
return NULL;
} }
spin_lock_irq(&gb_interfaces_lock); spin_lock_irq(&gb_interfaces_lock);
...@@ -162,6 +159,13 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd, ...@@ -162,6 +159,13 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd,
spin_unlock_irq(&gb_interfaces_lock); spin_unlock_irq(&gb_interfaces_lock);
return intf; return intf;
free_intf:
put_device(&intf->dev);
kfree(intf);
put_module:
put_device(&module->dev);
return NULL;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment