From: Philipp Hortmann <philipp.g.hortmann@gmail.com>
To: xkernel.wang@foxmail.com, Larry.Finger@lwfinger.net,
phil@philpotter.co.uk, gregkh@linuxfoundation.org
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc()
Date: Fri, 9 Sep 2022 19:31:29 +0200 [thread overview]
Message-ID: <659ff470-a912-4f35-6cbe-e3f49ba29dc8@gmail.com> (raw)
In-Reply-To: <tencent_7705902B66DA5C1C0E3E8ACBF077A5C3FF07@qq.com>
On 9/9/22 13:44, xkernel.wang@foxmail.com wrote:
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
>
> In rtw_os_xmit_resource_alloc(), if usb_alloc_urb() fails, then the
> memory `pxmitbuf_pallocated_buf` which is allocated by kzalloc() is not
> properly released before returning.
>
> So this patch add kfree() on the above error path to release it. As there
> is no proper device to test with, no runtime testing was performed.
>
> Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
> ---
> ChangeLog:
> v1->v2 update the description.
> v2->v3 rebase.
> v3->v4 update the description.
> drivers/staging/r8188eu/os_dep/xmit_linux.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c
> index 89a598a..f25099d 100644
> --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c
> @@ -75,8 +75,10 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
> pxmitbuf->dma_transfer_addr = 0;
>
> pxmitbuf->pxmit_urb = usb_alloc_urb(0, GFP_KERNEL);
> - if (!pxmitbuf->pxmit_urb)
> + if (!pxmitbuf->pxmit_urb) {
> + kfree(pxmitbuf->pallocated_buf);
> return _FAIL;
> + }
>
> return _SUCCESS;
> }
Hi,
I cannot apply your patch:
kernel@matrix-ESPRIMO-P710:~/Documents/git/kernels/staging$ cat
~/Downloads/\[PATCH\ v4\]\ staging\ r8188eu\ fix\ potential\ memory\
leak\ in\ rtw_os_xmit_resource_alloc\(\).eml | git am
Applying: staging: r8188eu: fix potential memory leak in
rtw_os_xmit_resource_alloc()
error: drivers/staging/r8188eu/os_dep/xmit_linux.c: does not exist in index
Patch failed at 0001 staging: r8188eu: fix potential memory leak in
rtw_os_xmit_resource_alloc()
branch: staging-next
repository: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
Sorry
Bye Philipp
next prev parent reply other threads:[~2022-09-09 17:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 11:44 [PATCH v4] staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc() xkernel.wang
2022-09-09 17:31 ` Philipp Hortmann [this message]
2022-09-10 0:06 ` Xiaoke Wang
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=659ff470-a912-4f35-6cbe-e3f49ba29dc8@gmail.com \
--to=philipp.g.hortmann@gmail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=phil@philpotter.co.uk \
--cc=xkernel.wang@foxmail.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