2023-12-11 03:30:58

by Kunwu Chan

[permalink] [raw]
Subject: [PATCH] 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 <[email protected]>
Signed-off-by: Kunwu Chan <[email protected]>
---
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



2023-12-12 03:46:49

by Stanislaw Gruszka

[permalink] [raw]
Subject: Re: [PATCH] iwlegacy: Add null pointer check to il_leds_init

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 <[email protected]>
> Signed-off-by: Kunwu Chan <[email protected]>
Acked-by: Stanislaw Gruszka <[email protected]>

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

2023-12-12 15:35:42

by Kalle Valo

[permalink] [raw]
Subject: Re: wifi: iwlegacy: Add null pointer check to il_leds_init()

Kunwu Chan <[email protected]> wrote:

> kasprintf() returns a pointer to dynamically allocated memory
> which can be NULL upon failure.
>
> Cc: Kunwu Chan <[email protected]>
> Signed-off-by: Kunwu Chan <[email protected]>
> Acked-by: Stanislaw Gruszka <[email protected]>

Patch applied to wireless-next.git, thanks.

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

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches