From 71e4938012faff9b84916f5424dbf4dff8d1d09e Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Tue, 24 Mar 2015 20:14:29 +0530 Subject: [PATCH] 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 --- drivers/staging/greybus/interface.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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; } /* -- 2.11.0