diff options
author | Bjørn Mork <bjorn@mork.no> | 2014-05-30 03:31:04 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-06-02 19:01:30 -0400 |
commit | 1ba5d0ff36f765a571c83b55b13ec44f4050fb5b (patch) | |
tree | 67aa90e05b8c98166c96890bac664b61fdf876f5 | |
parent | 1e2c611723420789e6098534fc0c57f12ee041b7 (diff) |
net: cdc_ncm: always reallocate tx_curr_skb when tx_max increases
We are calling usbnet_start_xmit() to flush any remaining data,
depending on the side effect that tx_curr_skb is set to NULL,
ensuring a new allocation using the updated tx_max. But this
side effect will only happen if there were any cached data ready
to transmit. If not, then an empty tx_curr_skb is still allocated
using the old tx_max size. Free it to avoid a buffer overrun.
Fixes: 68864abf08f0 ("net: cdc_ncm: support rx_max/tx_max updates when running")
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/usb/cdc_ncm.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 2bbbd65591c7..ff5b3a854898 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c | |||
@@ -268,6 +268,11 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx) | |||
268 | if (netif_running(dev->net) && val > ctx->tx_max) { | 268 | if (netif_running(dev->net) && val > ctx->tx_max) { |
269 | netif_tx_lock_bh(dev->net); | 269 | netif_tx_lock_bh(dev->net); |
270 | usbnet_start_xmit(NULL, dev->net); | 270 | usbnet_start_xmit(NULL, dev->net); |
271 | /* make sure tx_curr_skb is reallocated if it was empty */ | ||
272 | if (ctx->tx_curr_skb) { | ||
273 | dev_kfree_skb_any(ctx->tx_curr_skb); | ||
274 | ctx->tx_curr_skb = NULL; | ||
275 | } | ||
271 | ctx->tx_max = val; | 276 | ctx->tx_max = val; |
272 | netif_tx_unlock_bh(dev->net); | 277 | netif_tx_unlock_bh(dev->net); |
273 | } else { | 278 | } else { |