From: Viresh Kumar Date: Tue, 24 Mar 2015 14:44:29 +0000 (+0530) Subject: greybus: interface: put module->dev on failures X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=71e4938012faff9b84916f5424dbf4dff8d1d09e;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index d2b2e3df33fa..b687908cfa16 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -132,7 +132,7 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd, intf = kzalloc(sizeof(*intf), GFP_KERNEL); if (!intf) - return NULL; + goto put_module; intf->hd = hd; /* XXX refcount? */ intf->module = module; @@ -151,10 +151,7 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd, if (retval) { pr_err("failed to add module device for id 0x%02hhx\n", module_id); - put_device(&intf->dev); - put_device(&module->dev); - kfree(intf); - return NULL; + goto free_intf; } spin_lock_irq(&gb_interfaces_lock); @@ -162,6 +159,13 @@ static struct gb_interface *gb_interface_create(struct greybus_host_device *hd, spin_unlock_irq(&gb_interfaces_lock); return intf; + +free_intf: + put_device(&intf->dev); + kfree(intf); +put_module: + put_device(&module->dev); + return NULL; } /*