]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
mt76: fix frag length allocation for usb
authorStanislaw Gruszka <sgruszka@redhat.com>
Wed, 3 Oct 2018 10:52:24 +0000 (12:52 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 5 Oct 2018 18:05:44 +0000 (20:05 +0200)
This is correct fix for c12128ce44b0 ("mt76: use a per rx queue page
fragment cache"). We use wrong length when we allocate segments for
MCU transmissions, which require bigger segment size than e->buf_size.

Commit 481bb0432414 ("mt76: usb: make rx page_frag_cache access atomic")
partially solved the problem or actually mask it by changing
mt76u_mcu_init_rx() and mt76u_alloc_queues() sequence, so e->buf_size
become non zero any longer, but still not big enough to handle MCU data.

Patch fixes memory corruption which can manifest itself as random,
not easy to reproduce crashes, during mt76 driver load or unload.

Fixes: c12128ce44b0 ("mt76: use a per rx queue page fragment cache")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/usb.c

index de7785c4f6af3811ad57c2887b394dbdb7b2bd99..6b643ea701e3875bee4eea1cb11a8846e1c1171f 100644 (file)
@@ -286,7 +286,7 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf,
                void *data;
                int offset;
 
-               data = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC);
+               data = page_frag_alloc(&q->rx_page, len, GFP_ATOMIC);
                if (!data)
                        break;