public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: Improve error handling
@ 2026-03-13 12:49 Bera Yüzlü
  2026-03-13 14:01 ` Greg KH
  2026-03-16  8:19 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Bera Yüzlü @ 2026-03-13 12:49 UTC (permalink / raw)
  To: gregkh; +Cc: ethantidmore06, linux-staging, linux-kernel, Bera Yüzlü

Remove unnecessary ret variable and goto exit pattern. The function now
returns immediately when an error occurs. Additionally, ensure that
intf_free_irq() is called when pm_netdev_open() fails to avoid leaving
the allocated IRQ uncleared.

Signed-off-by: Bera Yüzlü <b9788213@gmail.com>
---
V2: Used int_free_irq() in error condition.
V1 Link: https://lore.kernel.org/linux-staging/20260312131933.29505-2-b9788213@gmail.com/
 drivers/staging/rtl8723bs/os_dep/os_intfs.c | 28 ++++++++-------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 7ba689f2d..e86b8af8b 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -1124,35 +1124,28 @@ static int rtw_resume_process_normal(struct adapter *padapter)
 	struct pwrctrl_priv *pwrpriv;
 	struct mlme_priv *pmlmepriv;
 
-	int ret = _SUCCESS;
-
-	if (!padapter) {
-		ret = -1;
-		goto exit;
-	}
+	if (!padapter)
+		return -1;
 
 	pnetdev = padapter->pnetdev;
 	pwrpriv = adapter_to_pwrctl(padapter);
 	pmlmepriv = &padapter->mlmepriv;
 	/*  interface init */
 	/* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */
-	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-		ret = -1;
-		goto exit;
-	}
+	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS))
+		return -1;
+
 	rtw_hal_disable_interrupt(padapter);
 	/* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */
-	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-		ret = -1;
-		goto exit;
-	}
+	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS))
+		return -1;
 
 	rtw_reset_drv_sw(padapter);
 	pwrpriv->bkeepfwalive = false;
 
 	if (pm_netdev_open(pnetdev, true) != 0) {
-		ret = -1;
-		goto exit;
+		padapter->intf_free_irq(adapter_to_dvobj(padapter));
+		return -1;
 	}
 
 	netif_device_attach(pnetdev);
@@ -1168,8 +1161,7 @@ static int rtw_resume_process_normal(struct adapter *padapter)
 		rtw_ap_restore_network(padapter);
 	}
 
-exit:
-	return ret;
+	return _SUCCESS;
 }
 
 int rtw_resume_common(struct adapter *padapter)
-- 
2.43.0


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

* Re: [PATCH] staging: rtl8723bs: Improve error handling
  2026-03-13 12:49 [PATCH] staging: rtl8723bs: Improve error handling Bera Yüzlü
@ 2026-03-13 14:01 ` Greg KH
  2026-03-16  8:19 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-03-13 14:01 UTC (permalink / raw)
  To: Bera Yüzlü; +Cc: ethantidmore06, linux-staging, linux-kernel

On Fri, Mar 13, 2026 at 03:49:08PM +0300, Bera Yüzlü wrote:
> Remove unnecessary ret variable and goto exit pattern. The function now
> returns immediately when an error occurs. Additionally, ensure that
> intf_free_irq() is called when pm_netdev_open() fails to avoid leaving
> the allocated IRQ uncleared.
> 
> Signed-off-by: Bera Yüzlü <b9788213@gmail.com>
> ---
> V2: Used int_free_irq() in error condition.

No "v2" in the [PATCH] area?  It should look like:
	[PATCH v2] staging: rtl8723bs: Improve error handling

so, v3?

thanks,

greg k-h

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

* Re: [PATCH] staging: rtl8723bs: Improve error handling
  2026-03-13 12:49 [PATCH] staging: rtl8723bs: Improve error handling Bera Yüzlü
  2026-03-13 14:01 ` Greg KH
@ 2026-03-16  8:19 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-03-16  8:19 UTC (permalink / raw)
  To: Bera Yüzlü; +Cc: gregkh, ethantidmore06, linux-staging, linux-kernel

On Fri, Mar 13, 2026 at 03:49:08PM +0300, Bera Yüzlü wrote:
> Remove unnecessary ret variable and goto exit pattern. The function now
> returns immediately when an error occurs. Additionally, ensure that
> intf_free_irq() is called when pm_netdev_open() fails to avoid leaving
> the allocated IRQ uncleared.
> 
> Signed-off-by: Bera Yüzlü <b9788213@gmail.com>
> ---
> V2: Used int_free_irq() in error condition.
> V1 Link: https://lore.kernel.org/linux-staging/20260312131933.29505-2-b9788213@gmail.com/
>  drivers/staging/rtl8723bs/os_dep/os_intfs.c | 28 ++++++++-------------
>  1 file changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
> index 7ba689f2d..e86b8af8b 100644
> --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
> +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
> @@ -1124,35 +1124,28 @@ static int rtw_resume_process_normal(struct adapter *padapter)
>  	struct pwrctrl_priv *pwrpriv;
>  	struct mlme_priv *pmlmepriv;
>  
> -	int ret = _SUCCESS;
> -
> -	if (!padapter) {
> -		ret = -1;
> -		goto exit;
> -	}
> +	if (!padapter)
> +		return -1;
>  
>  	pnetdev = padapter->pnetdev;
>  	pwrpriv = adapter_to_pwrctl(padapter);
>  	pmlmepriv = &padapter->mlmepriv;
>  	/*  interface init */
>  	/* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */
> -	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) {
> -		ret = -1;
> -		goto exit;
> -	}
> +	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS))
> +		return -1;
> +
>  	rtw_hal_disable_interrupt(padapter);
>  	/* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */
> -	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
> -		ret = -1;
> -		goto exit;
> -	}
> +	if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS))
> +		return -1;

I have written a howto on error handling.

https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/

So after the ->intf_init() you need a deinit() etc.  The blog hopefully
explains.

regards,
dan carpenter


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

end of thread, other threads:[~2026-03-16  8:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 12:49 [PATCH] staging: rtl8723bs: Improve error handling Bera Yüzlü
2026-03-13 14:01 ` Greg KH
2026-03-16  8:19 ` Dan Carpenter

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