public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iwlegacy/4965: Cancel deferred work on device init failure
@ 2025-03-04  3:16 Wentao Liang
  2025-03-04 16:44 ` Stanislaw Gruszka
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-03-04  3:16 UTC (permalink / raw)
  To: stf_xl, kvalo; +Cc: linux-wireless, linux-kernel, Wentao Liang

In __il4965_up(), deferred work is not canceled in time when device
initialization fails. This is harmless if the device has not started.
However, in il4965_bg_restart(), if the device remains operational
in any state other than S_FW_ERROR or S_EXIT_PENDING, a dereference
operation needs to be performed when __il4965_up() fails.

Add il4965_cancel_deferred_work() to the failure path of
__il4965_up() to prevent potential errors. Even if the current code
does not exhibit the described issues, adding this change can prevent
future problems at minimal cost, improving the robustness of the code.

Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/wireless/intel/iwlegacy/4965-mac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
index 05c4af41bdb9..3b21bd79f3a9 100644
--- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
@@ -5591,6 +5591,8 @@ __il4965_up(struct il_priv *il)
 	__il4965_down(il);
 	clear_bit(S_EXIT_PENDING, &il->status);
 
+	il4965_cancel_deferred_work(il);
+
 	/* tried to restart and config the device for as long as our
 	 * patience could withstand */
 	IL_ERR("Unable to initialize device after %d attempts.\n", i);
-- 
2.42.0.windows.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iwlegacy/4965: Cancel deferred work on device init failure
  2025-03-04  3:16 [PATCH] iwlegacy/4965: Cancel deferred work on device init failure Wentao Liang
@ 2025-03-04 16:44 ` Stanislaw Gruszka
  0 siblings, 0 replies; 2+ messages in thread
From: Stanislaw Gruszka @ 2025-03-04 16:44 UTC (permalink / raw)
  To: Wentao Liang; +Cc: kvalo, linux-wireless, linux-kernel

Hi

On Tue, Mar 04, 2025 at 11:16:03AM +0800, Wentao Liang wrote:
> In __il4965_up(), deferred work is not canceled in time when device
> initialization fails. This is harmless if the device has not started.
> However, in il4965_bg_restart(), if the device remains operational
> in any state other than S_FW_ERROR or S_EXIT_PENDING, a dereference
> operation needs to be performed when __il4965_up() fails.
>
> Add il4965_cancel_deferred_work() to the failure path of
> __il4965_up() to prevent potential errors. Even if the current code
> does not exhibit the described issues, adding this change can prevent
> future problems at minimal cost, improving the robustness of the code.

I think preventing potential future problems in this legacy driver
is not necessary since the driver will not be developed further.

> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/net/wireless/intel/iwlegacy/4965-mac.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
> index 05c4af41bdb9..3b21bd79f3a9 100644
> --- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
> +++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
> @@ -5591,6 +5591,8 @@ __il4965_up(struct il_priv *il)
>  	__il4965_down(il);
>  	clear_bit(S_EXIT_PENDING, &il->status);
>  
> +	il4965_cancel_deferred_work(il);

We can not cancel here as we have il->mutex locked, it will
deadlock in case of some pending work that holds the mutex.

>  	/* tried to restart and config the device for as long as our
>  	 * patience could withstand */
>  	IL_ERR("Unable to initialize device after %d attempts.\n", i);
> -- 
> 2.42.0.windows.2
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-04 16:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04  3:16 [PATCH] iwlegacy/4965: Cancel deferred work on device init failure Wentao Liang
2025-03-04 16:44 ` Stanislaw Gruszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox