diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-12-01 15:01:19 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2019-01-11 15:10:15 +0100 |
commit | 0ecf94dc3695a494dd4f495fc0913049d0e99891 (patch) | |
tree | dfe5aa8fffd1d60bab520a2c5a22518f4a502cd3 /drivers/net | |
parent | mt76: dma: remove napi from mt76_dma_rx_fill signature (diff) | |
download | linux-0ecf94dc3695a494dd4f495fc0913049d0e99891.tar.xz linux-0ecf94dc3695a494dd4f495fc0913049d0e99891.zip |
mt76: usb: do not build the skb if reported len does not fit in buf_size
Precompute data length in order to avoid to allocate the related
skb data structure if reported length does not fit in queue buf_size
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/usb.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index b061263453d4..14ff06c5764e 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -407,17 +407,15 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb) if (len < 0) return 0; + data_len = min_t(int, len, urb->sg[0].length - MT_DMA_HDR_LEN); + if (MT_DMA_HDR_LEN + data_len > SKB_WITH_OVERHEAD(q->buf_size)) + return 0; + skb = build_skb(data, q->buf_size); if (!skb) return 0; - data_len = min_t(int, len, urb->sg[0].length - MT_DMA_HDR_LEN); skb_reserve(skb, MT_DMA_HDR_LEN); - if (skb->tail + data_len > skb->end) { - dev_kfree_skb(skb); - return 1; - } - __skb_put(skb, data_len); len -= data_len; |