From: Tiger Yang Date: Thu, 2 Jun 2011 06:04:36 +0000 (+0800) Subject: ocfs2: free memory allocated by inode_init_security X-Git-Tag: next-20110823~65^2~2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d27fb6a99c41428464a60a4a76839c0c31366faf;p=karo-tx-linux.git ocfs2: free memory allocated by inode_init_security The LSM security_inode_init_security() hook allocates memory for xattr name and value, expecting the caller to release the memory afterwards. reported-by: Mimi Zohar Signed-off-by: Tiger Yang Signed-off-by: Joel Becker --- diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 81ecf9c0bf0a..fcd77a03fc63 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -7185,12 +7185,11 @@ int ocfs2_init_security_and_acl(struct inode *dir, { int ret = 0; struct buffer_head *dir_bh = NULL; - struct ocfs2_security_xattr_info si = { - .enable = 1, - }; + struct ocfs2_security_xattr_info si = {0, }; ret = ocfs2_init_security_get(inode, dir, qstr, &si); if (!ret) { + si.enable = 1; ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, si.name, si.value, si.value_len, XATTR_CREATE); @@ -7216,6 +7215,10 @@ int ocfs2_init_security_and_acl(struct inode *dir, ocfs2_inode_unlock(dir, 0); brelse(dir_bh); leave: + if (si.enable) { + kfree(si.name); + kfree(si.value); + } return ret; } /*