Skip to contentSkip to conversation

ocfs2: free memory allocated by security_inode_init_security

PATCH New Tiger Yang 3 participants 4 messages May 30, 2011 – May 31, 2011 OCFS2

lore
Share & tools
lore

Tiger Yang

author
#0 lore raw

PATCH 1/1 ocfs2: free memory allocated by security_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.

---
 fs/ocfs2/xattr.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/xattr.c +2 -0
index 81ecf9c..e9b031e 100644
@@ -7215,6 +7215,8 @@ int ocfs2_init_security_and_acl(struct inode *dir,
 
 	ocfs2_inode_unlock(dir, 0);
 	brelse(dir_bh);
+	kfree(si.name);
+	kfree(si.value);
 leave:
 	return ret;
 }
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 1/1 ocfs2: free memory allocated by security_inode_init_security

Quoted 6 lines · Tiger Yang

The LSM security_inode_init_security() hook allocates memory for xattr name and value, expecting the caller to release the memory afterwards.

Hi Tiger,

Thanks for taking a look. For the normal case, the memory is now freed, but not on failure.

thanks,

Mimi

Quoted 17 lines
---
 fs/ocfs2/xattr.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/xattr.c +2 -0
index 81ecf9c..e9b031e 100644
@@ -7215,6 +7215,8 @@ int ocfs2_init_security_and_acl(struct inode *dir,
 
 	ocfs2_inode_unlock(dir, 0);
 	brelse(dir_bh);
+	kfree(si.name);
+	kfree(si.value);
 leave:
 	return ret;
 }
author
#2 lore raw

PATCH 1/1 ocfs2: free memory allocated by security_inode_init_security

Quoted 3 lines · Mimi Zohar

Thanks for taking a look. For the normal case, the memory is now freed, but not on failure.

Hi, Mini,
Thanks point it out, I will resend the patch.

Regards,
Tiger

#3 lore raw

PATCH 1/1 ocfs2: free memory allocated by security_inode_init_security

In reply to Mimi Zohar
Quoted 7 lines · Mimi Zohar
Quoted 6 lines · Tiger Yang

The LSM security_inode_init_security() hook allocates memory for xattr name and value, expecting the caller to release the memory afterwards.

Quoted 8 lines

Hi Tiger,

Thanks for taking a look. For the normal case, the memory is now freed, but not on failure.

thanks,

Mimi

Move the frees below leave. And just to be safe, specifically init .name and .value to null while declaring.

Quoted 23 lines
Quoted 9 lines
---
  fs/ocfs2/xattr.c |    2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/xattr.c +0 -0
index 81ecf9c..e9b031e 100644

fs/ocfs2/xattr.c int ocfs2_init_security_and_acl(struct inode *dir, · line 7222

Quoted 8 lines
fs/ocfs2/xattr.c +2 -0
@@ -7215,6 +7215,8 @@ int ocfs2_init_security_and_acl(struct inode *dir,
 
  	ocfs2_inode_unlock(dir, 0);
  	brelse(dir_bh);
+	kfree(si.name);
+	kfree(si.value);
  leave:
  	return ret;
  }

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel