wifi: iwlegacy: Add null pointer check to il_leds_init()
authorKunwu Chan <chentao@kylinos.cn>
Mon, 11 Dec 2023 03:30:19 +0000 (11:30 +0800)
committerKalle Valo <kvalo@kernel.org>
Tue, 12 Dec 2023 15:35:20 +0000 (17:35 +0200)
kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.

Cc: Kunwu Chan <kunwu.chan@hotmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231211033019.238149-1-chentao@kylinos.cn
drivers/net/wireless/intel/iwlegacy/common.c

index 054fef680aba0e2498b48873184d5238bea1f6a1..17570d62c896183915cbf9acfd6a82c1bc60ab7b 100644 (file)
@@ -541,6 +541,9 @@ il_leds_init(struct il_priv *il)
 
        il->led.name =
            kasprintf(GFP_KERNEL, "%s-led", wiphy_name(il->hw->wiphy));
+       if (!il->led.name)
+               return;
+
        il->led.brightness_set = il_led_brightness_set;
        il->led.blink_set = il_led_blink_set;
        il->led.max_brightness = 1;