net: moxa: fix TX overrun memory leak
authorJonas Jensen <jonas.jensen@gmail.com>
Tue, 28 Mar 2017 10:12:38 +0000 (12:12 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Dec 2017 13:23:42 +0000 (14:23 +0100)
commit55b6a5d080aaf42aad34a4866c27a185b91f7a26
tree8e8faf47b69615c0c4215c0e914c631b1dcd1899
parentce19146a0de06d512c6565e7374f01335d87bf65
net: moxa: fix TX overrun memory leak

[ Upstream commit c2b341a620018d4eaeb0e85c16274ac4e5f153d4 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/moxa/moxart_ether.c
drivers/net/ethernet/moxa/moxart_ether.h