Skip to content

Commit 114b80c

Browse files
committed
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>
1 parent 8765489 commit 114b80c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎fs/gfs2/xattr.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,10 @@ int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **ppdata)
549549
goto out;
550550

551551
error = gfs2_ea_get_copy(ip, &el, data, len);
552-
if (error == 0)
553-
error = len;
554-
*ppdata = data;
552+
if (error < 0)
553+
kfree(data);
554+
else
555+
*ppdata = data;
555556
out:
556557
brelse(el.el_bh);
557558
return error;

0 commit comments

Comments
 (0)