staging: rtl8188eu: Fix null pointer dereference on free_netdev call

An unregister_netdev call checks if pnetdev is null, hence a later
call to free_netdev can potentially be passing a null pointer, causing
a null pointer dereference. Avoid this by adding a null pointer check
on pnetdev before calling free_netdev.

Fixes: 1665c8fdff ("staging: rtl8188eu: use netdev routines for private data")
Reviewed-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210324152135.254152-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Colin Ian King 2021-03-24 15:21:35 +00:00 коммит произвёл Greg Kroah-Hartman
Родитель d8827ae8e2
Коммит 0933e51a0b
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -446,7 +446,8 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
pr_debug("+r871xu_dev_remove, hw_init_completed=%d\n",
if1->hw_init_completed);
rtw_free_drv_sw(if1);
free_netdev(pnetdev);
if (pnetdev)
free_netdev(pnetdev);
}
static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)