diff mbox series

iwlegacy: Add null pointer check to il_leds_init

Message ID 20231211033019.238149-1-chentao@kylinos.cn (mailing list archive)
State Accepted
Commit afd549903ea98bd21b9db2a409b227e893b7a70f
Delegated to: Kalle Valo
Headers show
Series iwlegacy: Add null pointer check to il_leds_init | expand

Commit Message

Kunwu Dec. 11, 2023, 3:30 a.m. UTC
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>
---
 drivers/net/wireless/intel/iwlegacy/common.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stanislaw Gruszka Dec. 12, 2023, 3:46 a.m. UTC | #1
On Mon, Dec 11, 2023 at 11:30:19AM +0800, Kunwu Chan wrote:
> 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>

> ---
>  drivers/net/wireless/intel/iwlegacy/common.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
> index 054fef680aba..17570d62c896 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;
> -- 
> 2.39.2
>
Kalle Valo Dec. 12, 2023, 3:35 p.m. UTC | #2
Kunwu Chan <chentao@kylinos.cn> wrote:

> 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>

Patch applied to wireless-next.git, thanks.

afd549903ea9 wifi: iwlegacy: Add null pointer check to il_leds_init()
diff mbox series

Patch

diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
index 054fef680aba..17570d62c896 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;