Skip to content

Commit

Permalink
[PATCH] drivers/char/ipmi/ipmi_msghandler.c: fix a memory leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Adrian Bunk authored and Linus Torvalds committed Mar 25, 2006
1 parent 7e31765 commit 5c98d29
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/char/ipmi/ipmi_msghandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,8 @@ int ipmi_create_user(unsigned int if_num,
intf = ipmi_interfaces[if_num];
if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
spin_unlock_irqrestore(&interfaces_lock, flags);
return -EINVAL;
rv = -EINVAL;
goto out_kfree;
}

/* Note that each existing user holds a refcount to the interface. */
Expand All @@ -751,14 +752,14 @@ int ipmi_create_user(unsigned int if_num,

if (!try_module_get(intf->handlers->owner)) {
rv = -ENODEV;
goto out_err;
goto out_kref;
}

if (intf->handlers->inc_usecount) {
rv = intf->handlers->inc_usecount(intf->send_info);
if (rv) {
module_put(intf->handlers->owner);
goto out_err;
goto out_kref;
}
}

Expand All @@ -769,9 +770,10 @@ int ipmi_create_user(unsigned int if_num,
*user = new_user;
return 0;

out_err:
kfree(new_user);
out_kref:
kref_put(&intf->refcount, intf_free);
out_kfree:
kfree(new_user);
return rv;
}

Expand Down

0 comments on commit 5c98d29

Please sign in to comment.