[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4d3634c3-3eaa-4fa9-a5c1-2156a298e95a@oracle.com>
Date: Thu, 18 Dec 2025 08:31:36 -0800
From: samasth.norway.ananda@...cle.com
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: gregkh@...uxfoundation.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [External] : Re: [PATCH 4/4] staging: rtl8723bs: check return
value of rtw_wdev_alloc()
On 12/17/25 11:12 PM, Dan Carpenter wrote:
> On Wed, Dec 17, 2025 at 05:14:14PM -0800, Samasth Norway Ananda wrote:
>> Add missing error check for rtw_wdev_alloc() in rtw_sdio_if1_init().
>>
>> rtw_wdev_alloc() can fail with -ENOMEM when wiphy_new() or rtw_zmalloc()
>> fails, or with other negative error codes when wiphy_register() fails.
>> Without checking the return value, initialization continues even when
>> wireless device allocation fails, potentially leaving the adapter in an
>> inconsistent state.
>>
>> Jump to the error cleanup path when rtw_wdev_alloc() fails to ensure
>> proper resource cleanup and prevent use of an incompletely initialized
>> adapter.
>>
>> Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@...cle.com>
>> ---
>> drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
>> index 1d0239eef114..432bc6aa1d90 100644
>> --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
>> +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
>> @@ -296,7 +296,8 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
>> if (rtw_init_drv_sw(padapter) == _FAIL)
>
> This call to rtw_init_drv_sw() does a number of allocations.
>
>> goto free_hal_data;
>>
>> - rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj));
>> + if (rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj)))
>> + goto free_hal_data;
>
> So this goto should free them as well. I have a blog about how to
> write cleanup code in a systematic way.
>
> https://urldefense.com/v3/__https://staticthinking.wordpress.com/2022/04/28/free-the-last-thing-style/__;!!ACWV5N9M2RV99hQ!KLPxUw-pZDgh7c5bRyLHFbR9D8QxefnIaHlNgp3DJsspN6yXrwFMCjE6xJIAZhqLWNIzorGl1tTzvpkYINf88wiRyerJrpTr$
Oh okay. Thanks Dan i'll go through it.
regards,
Samasth.
>
> regards,
> dan carpenter
>
Powered by blists - more mailing lists