Skip to content

Commit 681daee

Browse files
Jason Wangdavem330
authored andcommitted
virtio-net: correct error handling of virtqueue_kick()
Current error handling of virtqueue_kick() was wrong in two places: - The skb were freed immediately when virtqueue_kick() fail during xmit. This may lead double free since the skb was not detached from the virtqueue. - try_fill_recv() returns false when virtqueue_kick() fail. This will lead unnecessary rescheduling of refill work. Actually, it's safe to just ignore the kick failure in those two places. So this patch fixes this by partially revert commit 6797590. Fixes 6797590 (virtio_net: verify if virtqueue_kick() succeeded). Cc: Heinz Graalfs <graalfs@linux.vnet.ibm.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent de14439 commit 681daee

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/net/virtio_net.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,7 @@ static bool try_fill_recv(struct receive_queue *rq, gfp_t gfp)
671671
if (err)
672672
break;
673673
} while (rq->vq->num_free);
674-
if (unlikely(!virtqueue_kick(rq->vq)))
675-
return false;
674+
virtqueue_kick(rq->vq);
676675
return !oom;
677676
}
678677

@@ -877,7 +876,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
877876
err = xmit_skb(sq, skb);
878877

879878
/* This should not happen! */
880-
if (unlikely(err) || unlikely(!virtqueue_kick(sq->vq))) {
879+
if (unlikely(err)) {
881880
dev->stats.tx_fifo_errors++;
882881
if (net_ratelimit())
883882
dev_warn(&dev->dev,
@@ -886,6 +885,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
886885
kfree_skb(skb);
887886
return NETDEV_TX_OK;
888887
}
888+
virtqueue_kick(sq->vq);
889889

890890
/* Don't wait up for transmitted skbs to be freed. */
891891
skb_orphan(skb);

0 commit comments

Comments
 (0)