[PATCH 07/12] staging: ks7010: move null check before dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Smatch emits warn: variable dereferenced before check 'skb'.
This is not strictly a bug because the null check is not for
error checking but rather for a decision branch later in the code. However
it is still cleaner to have the code that does the null check to be
placed before the dereference.

Move null check code to be before dereference.

Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---
 drivers/staging/ks7010/ks_hostif.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 2917dda..6fc8360 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1128,13 +1128,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	int ret;
 	int no_key;
 
-	skb_len = skb->len;
-	if (skb_len > ETH_FRAME_LEN) {
-		DPRINTK(1, "bad length skb_len=%d\n", skb_len);
-		ret = -EOVERFLOW;
-		goto err_kfree_skb;
-	}
-
 	if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) ||
 	    (priv->connect_status & FORCE_DISCONNECT) ||
 	    priv->wpa.mic_failure.stop) {
@@ -1147,6 +1140,13 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 		return 0;
 	}
 
+	skb_len = skb->len;
+	if (skb_len > ETH_FRAME_LEN) {
+		DPRINTK(1, "bad length skb_len=%d\n", skb_len);
+		ret = -EOVERFLOW;
+		goto err_kfree_skb;
+	}
+
 	/* for PowerSave */
 	if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {	/* power save wakeup */
 		if (!netif_queue_stopped(priv->net_dev))
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux