[PATCH] drivers/char/ipmi/ipmi_msghandler.c: fix a memory leak
The Coverity checker found this memory leak. Signed-off-by: Adrian Bunk <bunk@stusta.de> Acked-by: Corey Minyard <minyard@acm.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
7e31765550
commit
5c98d29ae4
1 changed files with 7 additions and 5 deletions
|
@ -736,7 +736,8 @@ int ipmi_create_user(unsigned int if_num,
|
||||||
intf = ipmi_interfaces[if_num];
|
intf = ipmi_interfaces[if_num];
|
||||||
if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
|
if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
|
||||||
spin_unlock_irqrestore(&interfaces_lock, flags);
|
spin_unlock_irqrestore(&interfaces_lock, flags);
|
||||||
return -EINVAL;
|
rv = -EINVAL;
|
||||||
|
goto out_kfree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note that each existing user holds a refcount to the interface. */
|
/* Note that each existing user holds a refcount to the interface. */
|
||||||
|
@ -751,14 +752,14 @@ int ipmi_create_user(unsigned int if_num,
|
||||||
|
|
||||||
if (!try_module_get(intf->handlers->owner)) {
|
if (!try_module_get(intf->handlers->owner)) {
|
||||||
rv = -ENODEV;
|
rv = -ENODEV;
|
||||||
goto out_err;
|
goto out_kref;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intf->handlers->inc_usecount) {
|
if (intf->handlers->inc_usecount) {
|
||||||
rv = intf->handlers->inc_usecount(intf->send_info);
|
rv = intf->handlers->inc_usecount(intf->send_info);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
module_put(intf->handlers->owner);
|
module_put(intf->handlers->owner);
|
||||||
goto out_err;
|
goto out_kref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,9 +770,10 @@ int ipmi_create_user(unsigned int if_num,
|
||||||
*user = new_user;
|
*user = new_user;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_err:
|
out_kref:
|
||||||
kfree(new_user);
|
|
||||||
kref_put(&intf->refcount, intf_free);
|
kref_put(&intf->refcount, intf_free);
|
||||||
|
out_kfree:
|
||||||
|
kfree(new_user);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue