aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/xattr.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2011-11-09 07:54:43 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2011-11-09 07:54:43 -0500
commit114b80ce2c05f91f10fffbf303080357d73c0675 (patch)
tree3a4804a7cf7515d07baf9fbf899c07c95297f6ce /fs/gfs2/xattr.c
parent87654896ca619ff64f94d3881d6bd0ec7b29e25f (diff)
GFS2: Fix very unlikley memory leak in ACL xattr code
This was spotted by automated code analysis. In case reading an ACL xattr failed (only likely to happen if there is an I/O error for example, and even then only with unstuffed xattrs, so pretty difficult to trigger) a small amount of memory could potentially be leaked. This patch adds a kfree to the error path, and also removes a test which is no longer required (gfs2_ea_get_copy always returns either a negative error, or a length) Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/xattr.c')
-rw-r--r--fs/gfs2/xattr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 71d7bf830c09..a201a1d57a6d 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -549,9 +549,10 @@ int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **ppdata)
549 goto out; 549 goto out;
550 550
551 error = gfs2_ea_get_copy(ip, &el, data, len); 551 error = gfs2_ea_get_copy(ip, &el, data, len);
552 if (error == 0) 552 if (error < 0)
553 error = len; 553 kfree(data);
554 *ppdata = data; 554 else
555 *ppdata = data;
555out: 556out:
556 brelse(el.el_bh); 557 brelse(el.el_bh);
557 return error; 558 return error;