public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: Vihas Makwana <makvihas@gmail.com>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Straube <straube.linux@gmail.com>,
	Martin Kaiser <martin@kaiser.cx>,
	Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] staging: r8188eu: proper error handling in rtw_init_drv_sw
Date: Wed, 9 Mar 2022 00:13:50 +0300	[thread overview]
Message-ID: <b5f9dda7-269a-6b50-ddf2-b5fa05aa1d72@gmail.com> (raw)
In-Reply-To: <20220308205510.48431-3-makvihas@gmail.com>

Hi Vihas,

On 3/8/22 23:55, Vihas Makwana wrote:
> The code inside rtw_init_drv_sw() calls various init functions to
> populate the padapter structure and checks for their return values
> respectively.
> But if one of the functions in middle fails then it simply returns
> _FAIL instead of proper logging and calling freeing counterparts
> of previous init functions.
> This leads to various memory leaks and can be found in
> /sys/kernel/debug/kmemleak if kernel is compiled with DEBUG_KMEMLEAK=y.
> 
> Fix this and keep the success and error separate.
> 
> 
> Signed-off-by: Vihas Makwana <makvihas@gmail.com>
> ---

Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for 
RTL8188eu driver")
> Tested on Comfast CF-WU810N RTL8188EUS wireless adapter.
> This patch depends on "[PATCH 1/2] staging: r8188eu: call _cancel_timer_ex from
>   _rtw_free_recv_priv"
> ---

No need to say that 1/2 depends on 2/2 since they are already in same 
patch series :)

>   drivers/staging/r8188eu/os_dep/os_intfs.c | 60 ++++++++++++++++++-----
>   1 file changed, 47 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
> index 197568422..6279bba07 100644
> --- a/drivers/staging/r8188eu/os_dep/os_intfs.c
> +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
> @@ -469,32 +469,46 @@ u8 rtw_reset_drv_sw(struct adapter *padapter)
>   
>   u8 rtw_init_drv_sw(struct adapter *padapter)
>   {
> -	if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL)
> +	if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) {
> +		pr_err("rtw_init_cmd_priv failed\n");

Hm, what about
dev_err(dvobj_to_dev(padapter->dvobj), "..."); ?

IIRC it's main usb device for this driver.

@Phillip, @Larry, @Martin, please, correct me if I am wrong here


Random note: We can't use netdev_err here since rtw_init_drv_sw() is 
called before netdev registration


>   		return _FAIL;
> +	}
>   
>   	padapter->cmdpriv.padapter = padapter;

Otherwise looks good to me


With regards,
Pavel Skripkin

  reply	other threads:[~2022-03-08 21:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 20:55 [PATCH 0/2] staging: r8188eu: improve error handling Vihas Makwana
2022-03-08 20:55 ` [PATCH 1/2] staging: r8188eu: call _cancel_timer_ex from _rtw_free_recv_priv Vihas Makwana
2022-03-09  7:59   ` Dan Carpenter
2022-03-09  9:51     ` Vihas Makwana
2022-03-08 20:55 ` [PATCH 2/2] staging: r8188eu: proper error handling in rtw_init_drv_sw Vihas Makwana
2022-03-08 21:13   ` Pavel Skripkin [this message]
2022-03-09  8:02   ` Dan Carpenter

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=b5f9dda7-269a-6b50-ddf2-b5fa05aa1d72@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=makvihas@gmail.com \
    --cc=martin@kaiser.cx \
    --cc=phil@philpotter.co.uk \
    --cc=straube.linux@gmail.com \
    /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