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 <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
intf = kzalloc(sizeof(*intf), GFP_KERNEL);
if (!intf)
- return NULL;
+ goto put_module;
intf->hd = hd; /* XXX refcount? */
intf->module = module;
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);
spin_unlock_irq(&gb_interfaces_lock);
return intf;
+
+free_intf:
+ put_device(&intf->dev);
+ kfree(intf);
+put_module:
+ put_device(&module->dev);
+ return NULL;
}
/*