From: Chandra S Gorentla <csgorentla@gmail.com>
Date: Tue, 15 Sep 2015 12:39:51 +0000 (+0530)
Subject: drivers: staging: wilc1000: Add check for SPI availability
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7d05652c5ce812b4d1addd1a2733d20c912d528d;p=linux.git

drivers: staging: wilc1000: Add check for SPI availability

NULL pointer deference is observed in the wilc1000.ko module
with bus type SPI and when SPI is not ready.

Signed-off-by: Chandra S Gorentla <csgorentla@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index d8f17c6f9b5f5..9436eace44fa6 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1634,6 +1634,12 @@ int mac_open(struct net_device *ndev)
 	int i = 0;
 	struct WILC_WFI_priv *priv;
 
+#ifdef WILC_SPI
+	if (!g_linux_wlan || !g_linux_wlan->wilc_spidev) {
+		netdev_err(ndev, "wilc1000: SPI device not ready\n");
+		return -ENODEV;
+	}
+#endif
 	nic = netdev_priv(ndev);
 	priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
 	PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev);