[PATCH 4/5] staging: rtl8723bs: replace function with error handling alternative

Omer El Idrissi posted 5 patches 18 hours ago
[PATCH 4/5] staging: rtl8723bs: replace function with error handling alternative
Posted by Omer El Idrissi 18 hours ago
Replace the use of rtw_set_hal_ops with rtw_hal_data_init in
rtw_sdio_if1_init , which actually returns error or success and not
void.
rtw_set_hal_ops literally only calls rtw_hal_data_init and just ignores the
possibility of errors.

This is the only place this function is used, so remove it's unnecessary
definitions in include/sdio_hal.h as a prototype and os_dep/sdio_intf.c
as a function.

Signed-off-by: Omer El Idrissi <omer.e.idrissi@gmail.com>
---
 drivers/staging/rtl8723bs/include/sdio_hal.h |  1 -
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 11 +++--------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/sdio_hal.h b/drivers/staging/rtl8723bs/include/sdio_hal.h
index 6538253765f1..4ad145d5d33f 100644
--- a/drivers/staging/rtl8723bs/include/sdio_hal.h
+++ b/drivers/staging/rtl8723bs/include/sdio_hal.h
@@ -9,6 +9,5 @@
 
 u8 sd_int_isr(struct adapter *padapter);
 void sd_int_dpc(struct adapter *padapter);
-void rtw_set_hal_ops(struct adapter *padapter);
 
 #endif /* __SDIO_HAL_H__ */
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index 34ef40a86153..aea9b4e19874 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -197,12 +197,6 @@ static void sdio_dvobj_deinit(struct sdio_func *func)
 	}
 }
 
-void rtw_set_hal_ops(struct adapter *padapter)
-{
-	/* alloc memory for HAL DATA */
-	rtw_hal_data_init(padapter);
-}
-
 static void sd_intf_start(struct adapter *padapter)
 {
 	if (!padapter)
@@ -250,8 +244,9 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
 	/* 3 3. init driver special setting, interface, OS and hardware relative */
 
 	/* 4 3.1 set hardware operation functions */
-	rtw_set_hal_ops(padapter);
-
+	/* allocates padapter->HalData */
+	if (rtw_hal_data_init(padapter))
+		goto free_adapter;
 
 	/* 3 5. initialize Chip version */
 	padapter->intf_start = &sd_intf_start;
-- 
2.51.0
Re: [PATCH 4/5] staging: rtl8723bs: replace function with error handling alternative
Posted by Dan Carpenter an hour ago
On Tue, Mar 31, 2026 at 05:32:53PM +0200, Omer El Idrissi wrote:
> Replace the use of rtw_set_hal_ops with rtw_hal_data_init in
> rtw_sdio_if1_init , which actually returns error or success and not
> void.
> rtw_set_hal_ops literally only calls rtw_hal_data_init and just ignores the
> possibility of errors.
> 

This is a behavior change and it's quite dangerous.  A lot of code only
works because there is no error handling.  We can't merge it without
testing unless it causes a security issue or something.  For example,
not checking the results of allocations could cause a crash so maybe
that's a security bug.

> @@ -250,8 +244,9 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
>  	/* 3 3. init driver special setting, interface, OS and hardware relative */
>  
>  	/* 4 3.1 set hardware operation functions */
> -	rtw_set_hal_ops(padapter);
> -
> +	/* allocates padapter->HalData */
> +	if (rtw_hal_data_init(padapter))
> +		goto free_adapter;

I don't want to see checks in this style.  I always want them to be
in this format:

	ret = rtw_hal_data_init(padapter);
	if (ret)
		...

But in this case, just leave it because adding a new check would have
to be tested.

regards,
dan carpenter

>  
>  	/* 3 5. initialize Chip version */
>  	padapter->intf_start = &sd_intf_start;
> -- 
> 2.51.0
>