From: Kunwu Chan Date: Mon, 11 Dec 2023 03:30:19 +0000 (+0800) Subject: wifi: iwlegacy: Add null pointer check to il_leds_init() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=afd549903ea98bd21b9db2a409b227e893b7a70f;p=linux.git wifi: iwlegacy: Add null pointer check to il_leds_init() kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Cc: Kunwu Chan Signed-off-by: Kunwu Chan Acked-by: Stanislaw Gruszka Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20231211033019.238149-1-chentao@kylinos.cn --- diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 054fef680aba0..17570d62c8961 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.c +++ b/drivers/net/wireless/intel/iwlegacy/common.c @@ -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;