From: Krishna Kumar Date: Wed, 22 Oct 2008 09:18:36 +0000 (+0530) Subject: nfsd: Fix memory leak in nfsd_getxattr X-Git-Tag: v2.6.28-rc1~31^2~2 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=6c6a426fdcb374b7641d7cf9eea88410828b9d9a;p=linux-2.6-omap-h63xx.git nfsd: Fix memory leak in nfsd_getxattr Fix a memory leak in nfsd_getxattr. nfsd_getxattr should free up memory that it allocated if vfs_getxattr fails. Signed-off-by: Krishna Kumar Signed-off-by: J. Bruce Fields --- diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index aa1d0d6489a..9609eb51d72 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -410,6 +410,7 @@ out_nfserr: static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf) { ssize_t buflen; + ssize_t ret; buflen = vfs_getxattr(dentry, key, NULL, 0); if (buflen <= 0) @@ -419,7 +420,10 @@ static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf) if (!*buf) return -ENOMEM; - return vfs_getxattr(dentry, key, *buf, buflen); + ret = vfs_getxattr(dentry, key, *buf, buflen); + if (ret < 0) + kfree(*buf); + return ret; } #endif