]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.36.2/cifs-fix-another-memleak-in-cifs_root_iget.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.36.2 / cifs-fix-another-memleak-in-cifs_root_iget.patch
1 From a7851ce73b9fdef53f251420e6883cf4f3766534 Mon Sep 17 00:00:00 2001
2 From: Oskar Schirmer <oskar@scara.com>
3 Date: Wed, 10 Nov 2010 21:06:13 +0000
4 Subject: cifs: fix another memleak, in cifs_root_iget
5
6 From: Oskar Schirmer <oskar@scara.com>
7
8 commit a7851ce73b9fdef53f251420e6883cf4f3766534 upstream.
9
10 cifs_root_iget allocates full_path through
11 cifs_build_path_to_root, but fails to kfree it upon
12 cifs_get_inode_info* failure.
13
14 Make all failure exit paths traverse clean up
15 handling at the end of the function.
16
17 Signed-off-by: Oskar Schirmer <oskar@scara.com>
18 Reviewed-by: Jesper Juhl <jj@chaosbits.net>
19 Signed-off-by: Steve French <sfrench@us.ibm.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
21
22 ---
23 fs/cifs/inode.c | 12 ++++++------
24 1 file changed, 6 insertions(+), 6 deletions(-)
25
26 --- a/fs/cifs/inode.c
27 +++ b/fs/cifs/inode.c
28 @@ -835,8 +835,10 @@ struct inode *cifs_root_iget(struct supe
29 rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
30 xid, NULL);
31
32 - if (!inode)
33 - return ERR_PTR(rc);
34 + if (!inode) {
35 + inode = ERR_PTR(rc);
36 + goto out;
37 + }
38
39 #ifdef CONFIG_CIFS_FSCACHE
40 /* populate tcon->resource_id */
41 @@ -852,13 +854,11 @@ struct inode *cifs_root_iget(struct supe
42 inode->i_uid = cifs_sb->mnt_uid;
43 inode->i_gid = cifs_sb->mnt_gid;
44 } else if (rc) {
45 - kfree(full_path);
46 - _FreeXid(xid);
47 iget_failed(inode);
48 - return ERR_PTR(rc);
49 + inode = ERR_PTR(rc);
50 }
51
52 -
53 +out:
54 kfree(full_path);
55 /* can not call macro FreeXid here since in a void func
56 * TODO: This is no longer true