Skip to content

Commit 78a089d

Browse files
committed
Merge tag 'lsm-pr-20221031' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm
Pull LSM fix from Paul Moore: "A single patch to the capabilities code to fix a potential memory leak in the xattr allocation error handling" * tag 'lsm-pr-20221031' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm: capabilities: fix potential memleak on error path from vfs_getxattr_alloc()
2 parents 30a0b95 + 8cf0a1b commit 78a089d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

security/commoncap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,10 @@ int cap_inode_getsecurity(struct user_namespace *mnt_userns,
401401
&tmpbuf, size, GFP_NOFS);
402402
dput(dentry);
403403

404-
if (ret < 0 || !tmpbuf)
405-
return ret;
404+
if (ret < 0 || !tmpbuf) {
405+
size = ret;
406+
goto out_free;
407+
}
406408

407409
fs_ns = inode->i_sb->s_user_ns;
408410
cap = (struct vfs_cap_data *) tmpbuf;

0 commit comments

Comments
 (0)