Skip to content

Commit

Permalink
Sysfs: fix possible memleak in sysfs_follow_link
Browse files Browse the repository at this point in the history
There is the possiblity of a memory leak if a page is allocated and if
sysfs_getlink() fails in the sysfs_follow_link.

Signed-off-by: Armin Kuster <akuster@mvista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Armin Kuster authored and Greg Kroah-Hartman committed Jun 16, 2009
1 parent b22813b commit 557411e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/sysfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
{
int error = -ENOMEM;
unsigned long page = get_zeroed_page(GFP_KERNEL);
if (page)
if (page) {
error = sysfs_getlink(dentry, (char *) page);
if (error < 0)
free_page((unsigned long)page);
}
nd_set_link(nd, error ? ERR_PTR(error) : (char *)page);
return NULL;
}
Expand Down

0 comments on commit 557411e

Please sign in to comment.