Re: [PATCH v3] staging: r8188eu: add check for kzalloc

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

 



Thus wrote Jiasheng Jiang (jiasheng@xxxxxxxxxxx):

> As kzalloc() may return null pointer, it should be better to
> check the return value and return error if fails in order
> to avoid dereference of null pointer.
> Moreover, the return value of rtw_alloc_hwxmits() should also
> be dealt with.

> Fixes: 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
> ---
> Changelog

> v1 -> v2:

> *Change 1. Make rtw_alloc_hwxmits() return -ENOMEM on failure
> and zero on success.

> v2 -> v3

> *Change 1. Add "res = _FAIL".
> ---
>  drivers/staging/r8188eu/core/rtw_xmit.c    | 13 +++++++++++--
>  drivers/staging/r8188eu/include/rtw_xmit.h |  2 +-
>  2 files changed, 12 insertions(+), 3 deletions(-)

> diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
> index c2a550e7250e..2ee92bbe66a0 100644
> --- a/drivers/staging/r8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/r8188eu/core/rtw_xmit.c
> @@ -178,7 +178,12 @@ s32	_rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)

>  	pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;

> -	rtw_alloc_hwxmits(padapter);
> +	res = rtw_alloc_hwxmits(padapter);

This commit introduces a regression.

res is now 0 if the allocation succeeds.

> +	if (res) {
> +		res = _FAIL;
> +		goto exit;
> +	}
> +
>  	rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);

>  	for (i = 0; i < 4; i++)
> @@ -1474,7 +1479,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)


res is still 0 here - but the caller of _rtw_init_xmit_priv compares
this return value with _SUCCESS (1) or _FAIL (0) and interprets it as
_FAIL.

[ 3893.464932] r8188eu: module is from the staging directory, the quality is unknown, you have been warned.
[ 3893.543204] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0)
[ 3893.713123] EEPROM ID = 0x8129
[ 3893.719205] r8188eu 1-1.5:1.0: _rtw_init_xmit_priv failed
[ 3893.823102] usb 1-1.5: reset full-speed USB device number 4 using ci_hdrc
[ 3893.986936] usbcore: registered new interface driver r8188eu

>  	return res;
>  }




[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