Skip to contentSkip to conversation

wifi: cfg80211: tests: Fix potential NULL dereference in test_cfg80211_parse_colocated_ap()

PATCH New Gax-c 1 participant 1 message Nov 15, 2024 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

Gax-c

author
#0 lore raw

PATCH v2 1/1 wifi: cfg80211: tests: Fix potential NULL dereference in test_cfg80211_parse_colocated_ap()

From: Zichen Xie <[email protected]>

kunit_kzalloc() may return NULL, dereferencing it without NULL check may lead to NULL dereference.
Add a NULL check for ies.

Fixes 45d43937a44c ("wifi: cfg80211: add a kunit test for 6 GHz colocated AP parsing")

---
v2: Adjust subject.

---
 net/wireless/tests/scan.c | 2 ++
 1 file changed, 2 insertions(+)
net/wireless/tests/scan.c +2 -0
index 9f458be71659..79a99cf5e892 100644
@@ -810,6 +810,8 @@ static void test_cfg80211_parse_colocated_ap(struct kunit *test)
 		skb_put_data(input, "123", 3);
 
 	ies = kunit_kzalloc(test, struct_size(ies, data, input->len), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, ies);
+
 	ies->len = input->len;
 	memcpy(ies->data, input->data, input->len);
 
Signature · 1 line
2.34.1