]> git.ipfire.org Git - thirdparty/linux.git/commit
net: dsa: realtek: fix memory leak in rtl8366rb_setup_led()
authorDavid Yang <mmyangfl@gmail.com>
Thu, 18 Jun 2026 14:01:55 +0000 (22:01 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Jun 2026 00:46:18 +0000 (17:46 -0700)
commit056a5087d87ead77dedbe9cf5bde53b7cd4b4651
tree2fe47a57457d5389a5abed590d3cccbfae8a62ff
parentdb818b0e8af7bac16860116a19c341a63d6677b4
net: dsa: realtek: fix memory leak in rtl8366rb_setup_led()

led_classdev_register_ext() only reads init_data.devicename - it never
stores the pointer. However, the caller allocated devicename with
kasprintf() but never freed it, leaking the string memory.

Fix it with a stack buffer to avoid dynamic buffers completely.

Fixes: 32d617005475 ("net: dsa: realtek: add LED drivers for rtl8366rb")
Signed-off-by: David Yang <mmyangfl@gmail.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260618140200.1888707-1-mmyangfl@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/realtek/rtl8366rb-leds.c