memory leak in get_device_parent

From: syzbot
Date: Mon May 27 2019 - 20:51:36 EST


Hello,

syzbot found the following crash on:

HEAD commit: 35efb51e Merge tag 'ext4_for_linus_stable' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16577182a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=61dd9e15a761691d
dashboard link: https://syzkaller.appspot.com/bug?extid=02e97e2ad931a981e568
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12dd6b06a00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1128ae9aa00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+02e97e2ad931a981e568@xxxxxxxxxxxxxxxxxxxxxxxxx

8.129630][ T6979] RDX: 0000000000000000 RSI: 00000000400455c8 RDI: 0000000000000003
BUG: memory leak
unreferenced object 0xffff88812a7a6a80 (size 96):
comm "syz-executor898", pid 6976, jiffies 4295010285 (age 25.620s)
hex dump (first 32 bytes):
88 e0 e8 83 ff ff ff ff 88 6a 7a 2a 81 88 ff ff .........jz*....
88 6a 7a 2a 81 88 ff ff 00 00 00 00 00 00 00 00 .jz*............
backtrace:
[<00000000b0c40ba3>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
[<00000000b0c40ba3>] slab_post_alloc_hook mm/slab.h:439 [inline]
[<00000000b0c40ba3>] slab_alloc mm/slab.c:3326 [inline]
[<00000000b0c40ba3>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
[<00000000799c79a9>] kmalloc include/linux/slab.h:547 [inline]
[<00000000799c79a9>] kzalloc include/linux/slab.h:742 [inline]
[<00000000799c79a9>] class_dir_create_and_add drivers/base/core.c:1723 [inline]
[<00000000799c79a9>] get_device_parent.isra.0+0x1a8/0x240 drivers/base/core.c:1787
[<00000000b241fc22>] device_add+0x136/0x890 drivers/base/core.c:2048
[<00000000ee099a63>] hci_register_dev+0x166/0x380 net/bluetooth/hci_core.c:3305
[<00000000c362a920>] hci_uart_register_dev drivers/bluetooth/hci_ldisc.c:676 [inline]
[<00000000c362a920>] hci_uart_set_proto drivers/bluetooth/hci_ldisc.c:700 [inline]
[<00000000c362a920>] hci_uart_tty_ioctl+0x221/0x350 drivers/bluetooth/hci_ldisc.c:754
[<00000000de259614>] tty_ioctl+0x6e2/0xa30 drivers/tty/tty_io.c:2664
[<00000000f5bde6a4>] vfs_ioctl fs/ioctl.c:46 [inline]
[<00000000f5bde6a4>] file_ioctl fs/ioctl.c:509 [inline]
[<00000000f5bde6a4>] do_vfs_ioctl+0x62a/0x810 fs/ioctl.c:696
[<0000000040a4c505>] ksys_ioctl+0x86/0xb0 fs/ioctl.c:713
[<00000000e454fe0b>] __do_sys_ioctl fs/ioctl.c:720 [inline]
[<00000000e454fe0b>] __se_sys_ioctl fs/ioctl.c:718 [inline]
[<00000000e454fe0b>] __x64_sys_ioctl+0x1e/0x30 fs/ioctl.c:718
[<00000000475478db>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
[<00000000708a3428>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811893cf00 (size 96):
comm "syz-executor898", pid 6978, jiffies 4295011473 (age 13.740s)
hex dump (first 32 bytes):
88 e0 e8 83 ff ff ff ff 08 cf 93 18 81 88 ff ff ................
08 cf 93 18 81 88 ff ff 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000b0c40ba3>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
[<00000000b0c40ba3>] slab_post_alloc_hook mm/slab.h:439 [inline]
[<00000000b0c40ba3>] slab_alloc mm/slab.c:3326 [inline]
[<00000000b0c40ba3>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
[<00000000799c79a9>] kmalloc include/linux/slab.h:547 [inline]
[<00000000799c79a9>] kzalloc include/linux/slab.h:742 [inline]
[<00000000799c79a9>] class_dir_create_and_add drivers/base/core.c:1723 [inline]
[<00000000799c79a9>] get_device_parent.isra.0+0x1a8/0x240 drivers/base/core.c:1787
[<00000000b241fc22>] device_add+0x136/0x890 drivers/base/core.c:2048
[<00000000ee099a63>] hci_register_dev+0x166/0x380 net/bluetooth/hci_core.c:3305
[<00000000c362a920>] hci_uart_register_dev drivers/bluetooth/hci_ldisc.c:676 [inline]
[<00000000c362a920>] hci_uart_set_proto drivers/bluetooth/hci_ldisc.c:700 [inline]
[<00000000c362a920>] hci_uart_tty_ioctl+0x221/0x350 drivers/bluetooth/hci_ldisc.c:754
[<00000000de259614>] tty_ioctl+0x6e2/0xa30 drivers/tty/tty_io.c:2664
[<00000000f5bde6a4>] vfs_ioctl fs/ioctl.c:46 [inline]
[<00000000f5bde6a4>] file_ioctl fs/ioctl.c:509 [inline]
[<00000000f5bde6a4>] do_vfs_ioctl+0x62a/0x810 fs/ioctl.c:696
[<0000000040a4c505>] ksys_ioctl+0x86/0xb0 fs/ioctl.c:713
[<00000000e454fe0b>] __do_sys_ioctl fs/ioctl.c:720 [inline]
[<00000000e454fe0b>] __se_sys_ioctl fs/ioctl.c:718 [inline]
[<00000000e454fe0b>] __x64_sys_ioctl+0x1e/0x30 fs/ioctl.c:718
[<00000000475478db>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
[<00000000708a3428>] entry_SYSCALL_64_after_hwframe+0x44/0xa9



---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxxx

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches