[PATCH] staging: rtl8188eu: Fix potential NULL pointer dereference

Greg Kroah-Hartman gregkh at linuxfoundation.org
Wed Mar 13 18:00:16 UTC 2019


On Wed, Mar 13, 2019 at 12:11:30PM -0500, Aditya Pakki wrote:
> hwxmits is allocated via kcalloc and not checked for failure before its
> dereference. The patch fixes this problem similar to rtl8723bs.
> 
> Signed-off-by: Aditya Pakki <pakki001 at umn.edu>
> ---
>  drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index 1723a47a96b4..a557ed37923a 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -1512,6 +1512,10 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
>  
>  	pxmitpriv->hwxmits = kcalloc(pxmitpriv->hwxmit_entry,
>  				     sizeof(struct hw_xmit), GFP_KERNEL);
> +	if (!pxmitpriv->hwxmits) {
> +		DBG_88E("alloc hwxmits fail!...\n");

You never need to print a message for a memory allocation failure, that
happens by the function that tried to allocate the memory.

> +		return;

Shouldn't you return an error?

thanks,

greg k-h


More information about the devel mailing list