Re: [PATCH 1/5] staging: r8188eu: Remove wrappers for kalloc() and kzalloc()

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

 



On Thu, Aug 05, 2021 at 01:37:13PM -0500, Larry Finger wrote:
> diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
> index 4ac76ca6e383..d7d33e201f37 100644
> --- a/drivers/staging/r8188eu/core/rtw_cmd.c
> +++ b/drivers/staging/r8188eu/core/rtw_cmd.c
> @@ -1947,10 +1947,13 @@ static void c2h_wk_callback(struct work_struct *work)
>  		if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) {
>  			/* This C2H event is read, clear it */
>  			c2h_evt_clear(adapter);
> -		} else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) {
> -			/* This C2H event is not read, read & clear now */
> -			if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS)
> -				continue;
> +		} else {
> +			c2h_evt = kmalloc(16, GFP_KERNEL);
> +			if (c2h_evt) {
> +				/* This C2H event is not read, read & clear now */
> +				if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS)
> +					continue;

Not related to your patch (don't resend, please fix this in a follow on
patch if you want to) but this isn't correct.  If the allocation fails,
it leads to a NULL dereference.  Or if the c2h_evt_read() call fails
there needs to be a kfree(c2h_evt) before the continue.

> +			}
>  		}
>  

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