Commit d2ddce3df7c7e8bdabea6c2990589440cd50fa7d

Authored by Haiyang Zhang
Committed by Greg Kroah-Hartman
1 parent 6743ca71e1

hyperv: Fix the error processing in netvsc_send()

[ Upstream commit d953ca4ddf71aa91a4596b2ff7ff1598f6ad4708 ]

The existing code frees the skb in EAGAIN case, in which the skb will be
retried from upper layer and used again.
Also, the existing code doesn't free send buffer slot in error case, because
there is no completion message for unsent packets.
This patch fixes these problems.

(Please also include this patch for stable trees. Thanks!)

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 8 additions and 3 deletions Side-by-side Diff

drivers/net/hyperv/netvsc.c
... ... @@ -716,7 +716,7 @@
716 716 u64 req_id;
717 717 unsigned int section_index = NETVSC_INVALID_INDEX;
718 718 u32 msg_size = 0;
719   - struct sk_buff *skb;
  719 + struct sk_buff *skb = NULL;
720 720 u16 q_idx = packet->q_idx;
721 721  
722 722  
... ... @@ -743,8 +743,6 @@
743 743 packet);
744 744 skb = (struct sk_buff *)
745 745 (unsigned long)packet->send_completion_tid;
746   - if (skb)
747   - dev_kfree_skb_any(skb);
748 746 packet->page_buf_cnt = 0;
749 747 }
750 748 }
... ... @@ -805,6 +803,13 @@
805 803 } else {
806 804 netdev_err(ndev, "Unable to send packet %p ret %d\n",
807 805 packet, ret);
  806 + }
  807 +
  808 + if (ret != 0) {
  809 + if (section_index != NETVSC_INVALID_INDEX)
  810 + netvsc_free_send_slot(net_device, section_index);
  811 + } else if (skb) {
  812 + dev_kfree_skb_any(skb);
808 813 }
809 814  
810 815 return ret;