Re: [PATCH] staging: rtl8188eu: Fix potential NULL pointer dereference
From: Greg Kroah-Hartman
Date: Wed Mar 13 2019 - 14:00:19 EST
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@xxxxxxx>
> ---
> 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