linux-yocto/net/atm
Wang Liang 955f400e4f net: atm: fix memory leak in atm_register_sysfs when device_register fail
[ Upstream commit 0a228624bcc00af41f281a2a84c928595a74c17d ]

When device_register() return error in atm_register_sysfs(), which can be
triggered by kzalloc fail in device_private_init() or other reasons,
kmemleak reports the following memory leaks:

unreferenced object 0xffff88810182fb80 (size 8):
  comm "insmod", pid 504, jiffies 4294852464
  hex dump (first 8 bytes):
    61 64 75 6d 6d 79 30 00                          adummy0.
  backtrace (crc 14dfadaf):
    __kmalloc_node_track_caller_noprof+0x335/0x450
    kvasprintf+0xb3/0x130
    kobject_set_name_vargs+0x45/0x120
    dev_set_name+0xa9/0xe0
    atm_register_sysfs+0xf3/0x220
    atm_dev_register+0x40b/0x780
    0xffffffffa000b089
    do_one_initcall+0x89/0x300
    do_init_module+0x27b/0x7d0
    load_module+0x54cd/0x5ff0
    init_module_from_file+0xe4/0x150
    idempotent_init_module+0x32c/0x610
    __x64_sys_finit_module+0xbd/0x120
    do_syscall_64+0xa8/0x270
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

When device_create_file() return error in atm_register_sysfs(), the same
issue also can be triggered.

Function put_device() should be called to release kobj->name memory and
other device resource, instead of kfree().

Fixes: 1fa5ae857b ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: Wang Liang <wangliang74@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250901063537.1472221-1-wangliang74@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-09-09 18:50:20 +02:00
..
addr.c
addr.h
atm_misc.c
atm_sysfs.c
br2684.c
clip.c atm: clip: Fix NULL pointer dereference in vcc_sendmsg() 2025-07-17 18:30:47 +02:00
common.c atm: atmtcp: Prevent arbitrary write in atmtcp_recv_control(). 2025-09-04 14:28:45 +02:00
common.h
ioctl.c atm: Fix Use-After-Free in do_vcc_ioctl 2023-12-20 15:17:35 +01:00
Kconfig
lec_arpc.h
lec.c net: atm: fix /proc/net/atm/lec handling 2025-06-27 11:05:36 +01:00
lec.h
Makefile
mpc.c atm: Fix NULL pointer dereference 2025-04-10 14:31:55 +02:00
mpc.h
mpoa_caches.c
mpoa_caches.h
mpoa_proc.c
pppoatm.c
proc.c
protocols.h
pvc.c
raw.c atm: Revert atm_account_tx() if copy_from_iter_full() fails. 2025-06-27 11:05:34 +01:00
resources.c net: atm: fix memory leak in atm_register_sysfs when device_register fail 2025-09-09 18:50:20 +02:00
resources.h
signaling.c
signaling.h
svc.c