linux/fs/nilfs2
Pavel Skripkin 8fd0c1b064 nilfs2: fix memory leak in nilfs_sysfs_delete_device_group
My local syzbot instance hit memory leak in nilfs2.  The problem was in
missing kobject_put() in nilfs_sysfs_delete_device_group().

kobject_del() does not call kobject_cleanup() for passed kobject and it
leads to leaking duped kobject name if kobject_put() was not called.

Fail log:

  BUG: memory leak
  unreferenced object 0xffff8880596171e0 (size 8):
  comm "syz-executor379", pid 8381, jiffies 4294980258 (age 21.100s)
  hex dump (first 8 bytes):
    6c 6f 6f 70 30 00 00 00                          loop0...
  backtrace:
     kstrdup+0x36/0x70 mm/util.c:60
     kstrdup_const+0x53/0x80 mm/util.c:83
     kvasprintf_const+0x108/0x190 lib/kasprintf.c:48
     kobject_set_name_vargs+0x56/0x150 lib/kobject.c:289
     kobject_add_varg lib/kobject.c:384 [inline]
     kobject_init_and_add+0xc9/0x160 lib/kobject.c:473
     nilfs_sysfs_create_device_group+0x150/0x800 fs/nilfs2/sysfs.c:999
     init_nilfs+0xe26/0x12b0 fs/nilfs2/the_nilfs.c:637

Link: https://lkml.kernel.org/r/20210612140559.20022-1-paskripkin@gmail.com
Fixes: da7141fb78 ("nilfs2: add /sys/fs/nilfs2/<device> group")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Michael L. Semon <mlsemon35@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-06-24 19:40:53 -07:00
..
alloc.c
alloc.h
bmap.c
bmap.h
btnode.c
btnode.h
btree.c
btree.h
cpfile.c nilfs2: fix typos in comments 2021-05-06 19:24:13 -07:00
cpfile.h
dat.c
dat.h
dir.c
direct.c
direct.h
export.h
file.c nilfs2: convert to fileattr 2021-04-12 15:04:30 +02:00
gcinode.c
ifile.c
ifile.h
inode.c fs: make helpers idmap mount aware 2021-01-24 14:27:20 +01:00
ioctl.c nilfs2: fix typos in comments 2021-05-06 19:24:13 -07:00
Kconfig
Makefile
mdt.c
mdt.h
namei.c Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2021-05-02 09:14:01 -07:00
nilfs.h nilfs2: convert to fileattr 2021-04-12 15:04:30 +02:00
page.c
page.h
recovery.c
segbuf.c block: rename BIO_MAX_PAGES to BIO_MAX_VECS 2021-03-11 07:47:48 -07:00
segbuf.h
segment.c fs/nilfs2: fix misspellings using codespell tool 2021-05-06 19:24:13 -07:00
segment.h
sufile.c
sufile.h
super.c
sysfs.c nilfs2: fix memory leak in nilfs_sysfs_delete_device_group 2021-06-24 19:40:53 -07:00
sysfs.h
the_nilfs.c nilfs2: fix typos in comments 2021-05-06 19:24:13 -07:00
the_nilfs.h block: use an on-stack bio in blkdev_issue_flush 2021-01-27 09:51:48 -07:00