Skip to contentSkip to conversation

wifi: nl80211: call kfree without a NULL check

PATCH In review Emmanuel Grumbach 2 participants 3 messages Oct 20, 2025 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: nl80211: call kfree without a NULL check

Coverity is unhappy because we may leak old_radio_rts_threshold. Since this pointer is only valid in the context of the function and kfree is NULL pointer safe, don't check and just call kfree.
Note that somehow, we were checking old_rts_threshold to free old_radio_rts_threshold which is a bit odd.

Fixes 264637941cf4 ("wifi: cfg80211: Add Support to Set RTS Threshold for each Radio")
---
 net/wireless/nl80211.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/wireless/nl80211.c +1 -2
index 346dfd2bd987..03d07b54359a 100644
@@ -4136,8 +4136,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 			rdev->wiphy.txq_quantum = old_txq_quantum;
 		}
 
-		if (old_rts_threshold)
-			kfree(old_radio_rts_threshold);
+		kfree(old_radio_rts_threshold);
 		return result;
 	}
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Emmanuel Grumbach

Coverity is unhappy because we may leak old_radio_rts_threshold.

Is this being flagged in a public Coverity instance?

I don't see this at either of:
https://scan.coverity.com/projects/linux
https://scan.coverity.com/projects/linux-next-weekly-scan

Quoted 1 line
Fixes 264637941cf4 ("wifi: cfg80211: Add Support to Set RTS Threshold for each Radio")

If there is a public instance, would be nice to add a Closes: tag that points to it

Quoted 1 line
Quoted 19 lines
---
 net/wireless/nl80211.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/wireless/nl80211.c +1 -2
index 346dfd2bd987..03d07b54359a 100644
@@ -4136,8 +4136,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 			rdev->wiphy.txq_quantum = old_txq_quantum;
 		}
 
-		if (old_rts_threshold)
-			kfree(old_radio_rts_threshold);
+		kfree(old_radio_rts_threshold);
 		return result;
 	}
 
#2 lore raw
Quoted 9 lines · Jeff Johnson
Quoted 1 line · Emmanuel Grumbach

Coverity is unhappy because we may leak old_radio_rts_threshold.

Is this being flagged in a public Coverity instance?

I don't see this at either of:
https://scan.coverity.com/projects/linux
https://scan.coverity.com/projects/linux-next-weekly-scan

Not that I am aware of. This was flagged by our internal instance.

Quoted 31 lines
Quoted 2 lines
Fixes 264637941cf4 ("wifi: cfg80211: Add Support to Set RTS

Threshold for each Radio")

If there is a public instance, would be nice to add a Closes: tag that points
to it

Quoted 1 line
Quoted 20 lines

---
 net/wireless/nl80211.c | 3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
net/wireless/nl80211.c +0 -0
index 346dfd2bd987..03d07b54359a 100644
@@ -4136,8 +4136,7 @@ static int nl80211_set_wiphy(struct sk_buff
 *skb, struct genl_info *info)
  			rdev->wiphy.txq_quantum = old_txq_quantum;
  		}

net/wireless/nl80211.c +1 -2
-		if (old_rts_threshold)
-			kfree(old_radio_rts_threshold);
+		kfree(old_radio_rts_threshold);

  return result;
  }