Skip to contentSkip to conversation

cifs: fix a memleak in cifs_setattr_nounix()

PATCH In review Suresh Jayaraman 3 participants 3 messages Nov 9, 2010 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: fix a memleak in cifs_setattr_nounix()

Andrew Hendry reported a kmemleak warning in 2.6.37-rc1 while editing a text file with gedit over cifs.

unreferenced object 0xffff88022ee08b40 (size 32):
comm "gedit", pid 2524, jiffies 4300160388 (age 2633.655s) hex dump (first 32 bytes):

    5c 2e 67 6f 75 74 70 75 74 73 74 72 65 61 6d 2d  \.goutputstream-
    35 42 41 53 4c 56 00 de 09 00 00 00 2c 26 78 ee  5BASLV......,&x.
  backtrace:
    [<ffffffff81504a4d>] kmemleak_alloc+0x2d/0x60
    [<ffffffff81136e13>] __kmalloc+0xe3/0x1d0
    [<ffffffffa0313db0>] build_path_from_dentry+0xf0/0x230 [cifs]
    [<ffffffffa031ae1e>] cifs_setattr+0x9e/0x770 [cifs]
    [<ffffffff8115fe90>] notify_change+0x170/0x2e0
    [<ffffffff81145ceb>] sys_fchmod+0x10b/0x140
    [<ffffffff8100c172>] system_call_fastpath+0x16/0x1b
    [<ffffffffffffffff>] 0xffffffffffffffff

The commit 1025774c that removed inode_setattr() seems to have introduced this memleak by returning early without freeing 'full_path'.

---
 fs/cifs/inode.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
fs/cifs/inode.c +0 -1
index 39869c3..ef3a55b 100644
@@ -2177,7 +2177,6 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 
 	setattr_copy(inode, attrs);
 	mark_inode_dirty(inode);
-	return 0;
 
 cifs_setattr_exit:
 	kfree(full_path);

A message that is not in the archive (sent off-list or not yet received): 1289285861-12033-1-git-send-email-sjayaraman-l3A5Bk7waGM@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 41 lines · On Tue, 9 Nov 2010 12:27:41 +0530 Suresh Jayaraman…

Andrew Hendry reported a kmemleak warning in 2.6.37-rc1 while editing a text file with gedit over cifs.

unreferenced object 0xffff88022ee08b40 (size 32):
comm "gedit", pid 2524, jiffies 4300160388 (age 2633.655s) hex dump (first 32 bytes):

    5c 2e 67 6f 75 74 70 75 74 73 74 72 65 61 6d 2d  \.goutputstream-
    35 42 41 53 4c 56 00 de 09 00 00 00 2c 26 78 ee  5BASLV......,&x.
  backtrace:
    [<ffffffff81504a4d>] kmemleak_alloc+0x2d/0x60
    [<ffffffff81136e13>] __kmalloc+0xe3/0x1d0
    [<ffffffffa0313db0>] build_path_from_dentry+0xf0/0x230 [cifs]
    [<ffffffffa031ae1e>] cifs_setattr+0x9e/0x770 [cifs]
    [<ffffffff8115fe90>] notify_change+0x170/0x2e0
    [<ffffffff81145ceb>] sys_fchmod+0x10b/0x140
    [<ffffffff8100c172>] system_call_fastpath+0x16/0x1b
    [<ffffffffffffffff>] 0xffffffffffffffff

The commit 1025774c that removed inode_setattr() seems to have introduced this memleak by returning early without freeing 'full_path'.

---
 fs/cifs/inode.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
fs/cifs/inode.c +0 -2
index 39869c3..ef3a55b 100644
@@ -2177,7 +2177,6 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 
 	setattr_copy(inode, attrs);
 	mark_inode_dirty(inode);
-	return 0;
 
 cifs_setattr_exit:
 	kfree(full_path);
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

That's almost certainly the bug.

A message that is not in the archive (sent off-list or not yet received): 20101109062024.010ab599-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#4 lore raw
Quoted 37 lines · Jeff Layton
Quoted 34 lines · On Tue,  9 Nov 2010 12:27:41 +0530 Suresh Jayaraman…

Andrew Hendry reported a kmemleak warning in 2.6.37-rc1 while editing a text file with gedit over cifs.

unreferenced object 0xffff88022ee08b40 (size 32):
  comm "gedit", pid 2524, jiffies 4300160388 (age 2633.655s) hex dump (first 32 bytes):
    5c 2e 67 6f 75 74 70 75 74 73 74 72 65 61 6d 2d  \.goutputstream- 35 42 41 53 4c 56 00 de 09 00 00 00 2c 26 78 ee  5BASLV......,&x. backtrace:

    [<ffffffff81504a4d>] kmemleak_alloc+0x2d/0x60
    [<ffffffff81136e13>] __kmalloc+0xe3/0x1d0
    [<ffffffffa0313db0>] build_path_from_dentry+0xf0/0x230 [cifs]
    [<ffffffffa031ae1e>] cifs_setattr+0x9e/0x770 [cifs]
    [<ffffffff8115fe90>] notify_change+0x170/0x2e0
    [<ffffffff81145ceb>] sys_fchmod+0x10b/0x140
    [<ffffffff8100c172>] system_call_fastpath+0x16/0x1b

    [<ffffffffffffffff>] 0xffffffffffffffff

The commit 1025774c that removed inode_setattr() seems to have introduced this memleak by returning early without freeing 'full_path'.

---
 fs/cifs/inode.c |    1 -

 1 files changed, 0 insertions(+), 1 deletions(-)
fs/cifs/inode.c +0 -0
index 39869c3..ef3a55b 100644
@@ -2177,7 +2177,6 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 
Quoted 8 lines
Quoted 6 lines
fs/cifs/inode.c +0 -1
       setattr_copy(inode, attrs);
       mark_inode_dirty(inode);
-     return 0;
 

 cifs_setattr_exit:
      kfree(full_path);

That's almost certainly the bug.

Yes. Agreed.

Merged.

Signature · 3 lines
Thanks,

Steve