Re: [PATCH v2 2/2] staging: r8188eu: fix potential memory leak in _rtw_init_xmit_priv()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 31, 2022 at 06:58:16PM +0800, xkernel.wang@xxxxxxxxxxx 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@xxxxxxxxxx>

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





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux