From: Armin Kuster Date: Wed, 29 Apr 2009 17:29:59 +0000 (-1000) Subject: Sysfs: fix possible memleak in sysfs_follow_link X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=557411eb2ce61ef5e87bd759a6f86881586df857;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git Sysfs: fix possible memleak in sysfs_follow_link 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index a3ba217fbe74..1d897ad808e0 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -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; }