Skip to contentSkip to conversation

wifi: mt76: mt7615: fix null pointer dereference bug

PATCH In review sicong 2 participants 2 messages May 13, 2024

Subsystems (2)
lore
Share & tools
lore

sicong

author
#0 lore raw

PATCH 1/1 wifi: mt76: mt7615: fix null pointer dereference bug

Function mt7615_coredump_work will call vzalloc to allocate a large amount of memory space, the size of which is 1300KB. There should be a null pointer check after vzalloc. Otherwise, when the memory allocation fails and returns NULL, the function will cause kernel crash.

Fixes de791098459d ("wifi: mt76: mt7615: fix null pointer dereference bug")
---
 drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -0
index 7ba789834e8d..04eb52904520 100644
@@ -2341,6 +2341,9 @@ void mt7615_coredump_work(struct work_struct *work)
 	}
 
 	dump = vzalloc(MT76_CONNAC_COREDUMP_SZ);
+	if(!dump)
+		return;
+
 	data = dump;
 
 	while (true) {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 27 lines

Function mt7615_coredump_work will call vzalloc to allocate a large amount of memory space, the size of which is 1300KB. There should be a null pointer check after vzalloc. Otherwise, when the memory allocation fails and returns NULL, the function will cause kernel crash.

Fixes de791098459d ("wifi: mt76: mt7615: fix null pointer dereference bug")
---
 drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -0
index 7ba789834e8d..04eb52904520 100644
@@ -2341,6 +2341,9 @@ void mt7615_coredump_work(struct work_struct *work)
 	}
 
 	dump = vzalloc(MT76_CONNAC_COREDUMP_SZ);
+	if(!dump)
+		return;
+
 	data = dump;
 
 	while (true) {
Signature · 1 line
2.34.1

I guess the kernel will not crash here since we check the dump pointer in the while loop, we will just flush the msg_list queue.

Regards,
Lorenzo