Skip to contentSkip to conversation

mt76: usb: check urb->num_sgs limit in mt76u_process_rx_entry

PATCH Applied [email protected] 2 participants 2 messages Feb 20, 2019 – Feb 26, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

[email protected]

author maintainer
#1 lore raw

PATCH 1/1 mt76: usb: check urb->num_sgs limit in mt76u_process_rx_entry

From: Lorenzo Bianconi <[email protected]>

check nsgs value is less than urb->num_sgs in mt76u_process_rx_entry in order to avoid an out-of-bound access of urb->sg array

---
 drivers/net/wireless/mediatek/mt76/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/usb.c +1 -1
index 78191968b4fa..5d7b57827d1e 100644
@@ -464,7 +464,7 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct mt76u_buf *buf)
 	__skb_put(skb, data_len);
 	len -= data_len;
 
-	while (len > 0 && urb->num_sgs) {
+	while (len > 0 && nsgs < urb->num_sgs) {
 		data_len = min_t(int, len, urb->sg[nsgs].length);
 		skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
 				sg_page(&urb->sg[nsgs]),
Signature · 1 line
2.20.1