Skip to content

Commit

Permalink
cifs: fix another memleak, in cifs_root_iget
Browse files Browse the repository at this point in the history
cifs_root_iget allocates full_path through
cifs_build_path_to_root, but fails to kfree it upon
cifs_get_inode_info* failure.

Make all failure exit paths traverse clean up
handling at the end of the function.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
Reviewed-by: Jesper Juhl <jj@chaosbits.net>
Cc: stable@kernel.org
Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Oskar Schirmer authored and Steve French committed Nov 11, 2010
1 parent ebe2e91 commit a7851ce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,10 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
xid, NULL);

if (!inode)
return ERR_PTR(rc);
if (!inode) {
inode = ERR_PTR(rc);
goto out;
}

#ifdef CONFIG_CIFS_FSCACHE
/* populate tcon->resource_id */
Expand All @@ -898,13 +900,11 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
inode->i_uid = cifs_sb->mnt_uid;
inode->i_gid = cifs_sb->mnt_gid;
} else if (rc) {
kfree(full_path);
_FreeXid(xid);
iget_failed(inode);
return ERR_PTR(rc);
inode = ERR_PTR(rc);
}


out:
kfree(full_path);
/* can not call macro FreeXid here since in a void func
* TODO: This is no longer true
Expand Down

0 comments on commit a7851ce

Please sign in to comment.