Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c6a426f authored by Krishna Kumar's avatar Krishna Kumar Committed by J. Bruce Fields
Browse files

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: default avatarKrishna Kumar <krkumar2@in.ibm.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 1cd9cd16
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -410,6 +410,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
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