lkml.org 
[lkml]   [2022]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/2] staging: r8188eu: fix potential memory leak in _rtw_init_xmit_priv()
On Thu, Mar 31, 2022 at 06:58:16PM +0800, xkernel.wang@foxmail.com wrote:
> +free_xmit_extbuf:
> + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
> + while (i-- > 0) {
> + rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ));
> + pxmitbuf++;
> + }
> + vfree(pxmitpriv->pallocated_xmit_extbuf);
> + i = NR_XMITBUFF;
> +free_xmitbuf:
> + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
> + while (i-- > 0) {
> + rtw_os_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
> + pxmitbuf++;
> + }

This works... Presumably, it applies to staging-next even though it
doesn't apply to linux-next. So:

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

In an ideal world, pxmitpriv->pxmitbuf would be declared as an array of
struct instead of an array of u8. That would make it much simpler
because we could do

free_xmit_extbuf:
while (--i >= 0)
rtw_os_xmit_resource_free(pxmitpriv->pxmit_extbuf[i]);
vfree(pxmitpriv->pxmit_extbuf);
i = NR_XMITBUFF;
free_xmitbuf:
while (--i >= 0)
rtw_os_xmit_resource_free(pxmitpriv->pxmitbuf[i]);

regards,
dan carpenter

\
 
 \ /
  Last update: 2022-03-31 13:24    [W:0.032 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site