Skip to contentSkip to conversation

staging: ks7010: Add null pointer check for skb

PATCH Superseded Aymen Qader 1 participant 2 messages Sep 27, 2018 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: ks7010: Add null pointer check for skb

Add a null pointer check for the socket buffer in ks_hostif.c to avoid a possible null pointer deference.

---
 drivers/staging/ks7010/ks_hostif.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/staging/ks7010/ks_hostif.c +5 -0
index 0e554e3359b5..4a5bc7858ef7 100644
@@ -1011,6 +1011,11 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	size_t size;
 	int ret;
 
+	if(!skb) {
+		ret = -ENOMEM;
+		goto err_kfree;
+	}
+
 	skb_len = skb->len;
 	if (skb_len > ETH_FRAME_LEN) {
 		netdev_err(priv->net_dev, "bad length skb_len=%d\n", skb_len);
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 staging: ks7010: Add null pointer check for skb

Add a null pointer check for the socket buffer in ks_hostif.c to avoid a possible null pointer deference, and remove a later now-redundant null pointer check.

---
v2: Remove redundant pointer check

 drivers/staging/ks7010/ks_hostif.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/staging/ks7010/ks_hostif.c +5 -1
index 0e554e3359b5..fdfee760a54f 100644
@@ -1011,6 +1011,11 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	size_t size;
 	int ret;
 
+	if(!skb) {
+		ret = -ENOMEM;
+		goto err_kfree;
+	}
+
 	skb_len = skb->len;
 	if (skb_len > ETH_FRAME_LEN) {
 		netdev_err(priv->net_dev, "bad length skb_len=%d\n", skb_len);
@@ -1023,7 +1028,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	    priv->wpa.mic_failure.stop) {
 		if (netif_queue_stopped(priv->net_dev))
 			netif_wake_queue(priv->net_dev);
-		if (skb)
 			dev_kfree_skb(skb);
 
 		return 0;
Signature · 1 line
2.17.1