public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: samasth.norway.ananda@oracle.com
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [External] : Re: [PATCH 4/4] staging: rtl8723bs: check return value of rtw_wdev_alloc()
Date: Thu, 18 Dec 2025 08:31:36 -0800	[thread overview]
Message-ID: <4d3634c3-3eaa-4fa9-a5c1-2156a298e95a@oracle.com> (raw)
In-Reply-To: <aUOpadPIsbYr-yI0@stanley.mountain>



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@oracle.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
> 


      reply	other threads:[~2025-12-18 16:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  1:14 [PATCH 0/4] staging: rtl8723bs: Fix error handling and memory Samasth Norway Ananda
2025-12-18  1:14 ` [PATCH 1/4] staging: rtl8723bs: fix firmware memory leak on error path Samasth Norway Ananda
2025-12-18  7:14   ` Dan Carpenter
2025-12-18 17:00     ` [External] : " samasth.norway.ananda
2025-12-18  1:14 ` [PATCH 2/4] staging: rtl8723bs: fix memory leak in rtw_cfg80211_inform_bss() Samasth Norway Ananda
2025-12-18  1:14 ` [PATCH 3/4] staging: rtl8723bs: add IS_ERR() check for kthread_run() Samasth Norway Ananda
2025-12-18  1:14 ` [PATCH 4/4] staging: rtl8723bs: check return value of rtw_wdev_alloc() Samasth Norway Ananda
2025-12-18  7:12   ` Dan Carpenter
2025-12-18 16:31     ` samasth.norway.ananda [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d3634c3-3eaa-4fa9-a5c1-2156a298e95a@oracle.com \
    --to=samasth.norway.ananda@oracle.com \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox