summaryrefslogtreecommitdiffstats
path: root/drivers/staging/wilc1000/linux_wlan.c
diff options
context:
space:
mode:
authorColin Ian King2018-09-11 19:38:51 +0200
committerGreg Kroah-Hartman2018-09-14 10:45:51 +0200
commitb4a01d8fa3116b8c2d1233f657f3c3db74b685aa (patch)
treef9de7f522b03cd4755b1bfb35e8309b3f21956ce /drivers/staging/wilc1000/linux_wlan.c
parentMerge tag 'iio-for-4.20a' of git://git.kernel.org/pub/scm/linux/kernel/git/ji... (diff)
downloadkernel-qcow2-linux-b4a01d8fa3116b8c2d1233f657f3c3db74b685aa.tar.gz
kernel-qcow2-linux-b4a01d8fa3116b8c2d1233f657f3c3db74b685aa.tar.xz
kernel-qcow2-linux-b4a01d8fa3116b8c2d1233f657f3c3db74b685aa.zip
staging: wilc1000: fix null checks on wilc
Currently the pointer wilc is being null checked several times and yet not checked for the final workqueue flush and destroy (which can lead to a null pointer dereference if wilc is null); these missing null checks were overlooked in an earlier core refactoring commit. Clean up the code by checking wilc at the start and bailing out early if it is null allowing the subsequent null checks to be removed, this also fixes the potential null pointer deferences on the workqueue flush and destroy calls. Detected by CoverityScan, CID#1473305 ("Dereference after null check") Fixes: b3ee105c332e ("staging: wilc1000: refactor code to move initilization in wilc_netdev_init()") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wilc1000/linux_wlan.c')
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 91a45a7c10ef..1d8de4dc9cf9 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1015,15 +1015,18 @@ void wilc_netdev_cleanup(struct wilc *wilc)
{
int i;
- if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev))
+ if (!wilc)
+ return;
+
+ if (wilc->vif[0]->ndev || wilc->vif[1]->ndev)
unregister_inetaddr_notifier(&g_dev_notifier);
- if (wilc && wilc->firmware) {
+ if (wilc->firmware) {
release_firmware(wilc->firmware);
wilc->firmware = NULL;
}
- if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
+ if (wilc->vif[0]->ndev || wilc->vif[1]->ndev) {
for (i = 0; i < NUM_CONCURRENT_IFC; i++)
if (wilc->vif[i]->ndev)
if (wilc->vif[i]->mac_opened)