Re: [PATCH net] net: dsa: realtek: fix memory leak in rtl8366rb_setup_led()
From: Linus Walleij
Date: Thu Jun 18 2026 - 18:58:47 EST
On Thu, Jun 18, 2026 at 4:02 PM David Yang <mmyangfl@xxxxxxxxx> wrote:
> 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@xxxxxxxxx>
Good catch!
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Yours,
Linus Walleij