Re: [PATCH] staging: rtl8192e: rtl_core: Fix possible null-pointer dereference in _rtl92e_pci_disconnect()

From: Dan Carpenter
Date: Wed Aug 11 2021 - 03:00:47 EST


On Tue, Aug 10, 2021 at 08:11:35PM -0700, Tuo Li wrote:
> The variable dev is checked in:
> if (dev)
>
> This indicates that it can be NULL. If so, a null-pointer dereference will
> occur:
> priv = rtllib_priv(dev);
>
> However, the value of priv is not used in the remaining part of this
> function. Thus the else-branch can be removed to fix this posible
> null-pointer dereference.
>
> Reported-by: TOTE Robot <oslab@xxxxxxxxxxxxxxx>
> Signed-off-by: Tuo Li <islituo@xxxxxxxxx>

Reviewed-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

Smatch was not smart enough to spot the dereference inside rtllib_priv().
Fortunately, the "dev" variable can't be NULL at this point.

regards,
dan carpenter