reiserfs: don't leak memory referenced by struct reiserfs_security_handle fields
PATCH 1/1 reiserfs: don't leak memory referenced by struct reiserfs_security_handle fields
Ever since its introduction in 2.6.30 reiserfs_security_free() was unused. Make all four users of reiserfs_security_init() use it. For this to be safe (avoiding attempts to free an uninitialized ->value member), remove a (now?) pointless shortcut from the latter function:security_old_inode_init_security() properly returns -EOPNOTSUPP when IS_PRIVATE(inode) (with the private flag getting propagated from dir), and hence the respective exit path can be used uniformly.
Signed-off-by Jan Beulich <[email protected]>
Cc Jeff Mahoney <[email protected]>
--- fs/reiserfs/namei.c | 4 ++++ fs/reiserfs/xattr_security.c | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-)
fs/reiserfs/namei.c +4 -0
@@ -688,6 +688,7 @@ static int reiserfs_create(struct inode out_failed:reiserfs_write_unlock (dir->i_sb); +reiserfs_security_free (&security);return retval; }
@@ -769,6 +770,7 @@ static int reiserfs_mknod(struct inode * out_failed:reiserfs_write_unlock (dir->i_sb); +reiserfs_security_free (&security);return retval; }
@@ -862,6 +864,7 @@ static int reiserfs_mkdir(struct inode * retval =journal_end (&th); out_failed:reiserfs_write_unlock (dir->i_sb); +reiserfs_security_free (&security);return retval; }
@@ -1167,6 +1170,7 @@ static int reiserfs_symlink(struct inode retval =journal_end (&th); out_failed:reiserfs_write_unlock (parent_dir->i_sb); +reiserfs_security_free (&security);return retval; }
fs/reiserfs/xattr_security.c +0 -6
@@ -60,12 +60,6 @@ int reiserfs_security_init(struct inodeint blocks =0 ;int error; - sec->name =NULL ; - -/* Don't add selinux attributes on xattrs - they'll never get used */ -if (IS_PRIVATE (dir)) -return 0 ; - error =security_old_inode_init_security (inode, dir, qstr, &sec->name, &sec->value, &sec->length);if (error) {