capabilities: fix potential memleak on error path from vfs_getxattr_alloc()
Changes
1 files changed · +4 −2
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| security/commoncap.c | modified | +4 | −2 | View file |
security/commoncap.c
View filediff --git a/security/commoncap.c b/security/commoncap.c
index 5fc8986..bc751fa 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -401,8 +401,10 @@ int cap_inode_getsecurity(struct user_namespace *mnt_userns,
&tmpbuf, size, GFP_NOFS);
dput(dentry);
- if (ret < 0 || !tmpbuf)
- return ret;
+ if (ret < 0 || !tmpbuf) {
+ size = ret;
+ goto out_free;
+ }
fs_ns = inode->i_sb->s_user_ns;
cap = (struct vfs_cap_data *) tmpbuf;