Skip to contentSkip to conversation

staging: rtl8192e: rtl_core: Fix possible null-pointer dereference in _rtl92e_pci_disconnect()

PATCH In review Tuo Li 2 participants 2 messages Aug 11, 2021 Staging

lore
Share & tools
lore

Tuo Li

author
#0 lore raw

PATCH 1/1 staging: rtl8192e: rtl_core: Fix possible null-pointer dereference in _rtl92e_pci_disconnect()

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.

---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +0 -2
index e85d9c2cdc96..0eb37a95b519 100644
@@ -2557,8 +2557,6 @@ static void _rtl92e_pci_disconnect(struct pci_dev *pdev)
 			release_mem_region(pci_resource_start(pdev, 1),
 					pci_resource_len(pdev, 1));
 		}
-	} else {
-		priv = rtllib_priv(dev);
 	}
 
 	pci_disable_device(pdev);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Tuo Li

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);

Quoted 6 lines

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.

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