]> git.baikalelectronics.ru Git - kernel.git/commit
net: moxa: fix TX overrun memory leak
authorJonas Jensen <jonas.jensen@gmail.com>
Tue, 28 Mar 2017 10:12:38 +0000 (12:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Mar 2017 01:02:05 +0000 (18:02 -0700)
commitda78d33767eed41488f94ba59b1c69100e3449de
tree28b751d30475eecc67268570c3d0f114b460a49f
parent4b7c3b24944b2ff5369a7ea9397ba7e42902396e
net: moxa: fix TX overrun memory leak

moxart_mac_start_xmit() doesn't care where tx_tail is, tx_head can
catch and pass tx_tail, which is bad because moxart_tx_finished()
isn't guaranteed to catch up on freeing resources from tx_tail.

Add a check in moxart_mac_start_xmit() stopping the queue at the
end of the circular buffer. Also add a check in moxart_tx_finished()
waking the queue if the buffer has TX_WAKE_THRESHOLD or more
free descriptors.

While we're at it, move spin_lock_irq() to happen before our
descriptor pointer is assigned in moxart_mac_start_xmit().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=99451

Signed-off-by: Jonas Jensen <jonas.jensen@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/moxa/moxart_ether.c
drivers/net/ethernet/moxa/moxart_ether.h