Skip to contentSkip to conversation

staging: rtl8723bs: Improve error handling

PATCH In review Bera Yüzlü 2 participants 2 messages Mar 13 – Mar 16 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 staging: rtl8723bs: Improve error handling

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.

---
V3: Fixed patch description.
V2: Used int_free_irq() in error condition.
V1 Link: https://lore.kernel.org/linux-staging/[email protected]/

 drivers/staging/rtl8723bs/os_dep/os_intfs.c | 28 ++++++++-------------
 1 file changed, 10 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/os_dep/os_intfs.c +10 -18
index 7ba689f2d..e86b8af8b 100644
@@ -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)
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · 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.

Quoted 7 lines

---
V3: Fixed patch description.
V2: Used int_free_irq() in error condition.
V1 Link: https://lore.kernel.org/linux-staging/[email protected]/

 drivers/staging/rtl8723bs/os_dep/os_intfs.c | 28 ++++++++-------------
 1 file changed, 10 insertions(+), 18 deletions(-)

I responded to v2. Same comments here.

regards,
dan carpenter