Skip to contentSkip to conversation

mac80211: potential null dereference in mesh forwarding

PATCH In review Dan Carpenter 2 participants 2 messages Jan 3, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: potential null dereference in mesh forwarding

The printk() is supposed to be ratelimited but we should always goto out when fwd_skb is NULL. Otherwise it gets dereferenced on the next line.

net/mac80211/rx.c +3 -2
index 5e9d3bc..dc8b566 100644
@@ -1831,8 +1831,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
 
 			fwd_skb = skb_copy(skb, GFP_ATOMIC);
 
-			if (!fwd_skb && net_ratelimit()) {
-				printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
+			if (!fwd_skb) {
+				if (net_ratelimit())
+					printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
 						   sdata->name);
 				goto out;
 			}
#1 lore raw
Quoted 11 lines · Dan Carpenter

The printk() is supposed to be ratelimited but we should always goto out when fwd_skb is NULL. Otherwise it gets dereferenced on the next line.

net/mac80211/rx.c +0 -0
index 5e9d3bc..dc8b566 100644
@@ -1831,8 +1831,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
 

net/mac80211/rx.c ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) · line 1839

Quoted 10 lines
net/mac80211/rx.c +3 -2
 			fwd_skb = skb_copy(skb, GFP_ATOMIC);
 
-			if (!fwd_skb && net_ratelimit()) {
-				printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
+			if (!fwd_skb) {
+				if (net_ratelimit())
+					printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
 						   sdata->name);
 				goto out;
 			}

Already discovered/coped by Milton Miller.