Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1638130 > unrolled thread

[PATCH v7 5/5] virtio_net: check return value of skb_to_sgvec always

Started by"Jason A. Donenfeld" <Jason@zx2c4.com>
First post2017-05-09 16:00 +0200
Last post2017-05-09 16:20 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v7 5/5] virtio_net: check return value of skb_to_sgvec always "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-05-09 16:00 +0200
    Re: [PATCH v7 5/5] virtio_net: check return value of skb_to_sgvec always "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-05-09 16:20 +0200

#1638130 — [PATCH v7 5/5] virtio_net: check return value of skb_to_sgvec always

From"Jason A. Donenfeld" <Jason@zx2c4.com>
Date2017-05-09 16:00 +0200
Subject[PATCH v7 5/5] virtio_net: check return value of skb_to_sgvec always
Message-ID<tFdQe-2qF-3@gated-at.bofh.it>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
---
 drivers/net/virtio_net.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f36584616e7d..1709fd0b4bf7 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1081,7 +1081,7 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 	struct virtio_net_hdr_mrg_rxbuf *hdr;
 	const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
 	struct virtnet_info *vi = sq->vq->vdev->priv;
-	unsigned num_sg;
+	int num_sg;
 	unsigned hdr_len = vi->hdr_len;
 	bool can_push;
 
@@ -1114,6 +1114,8 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 		sg_set_buf(sq->sg, hdr, hdr_len);
 		num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1;
 	}
+	if (unlikely(num_sg < 0))
+		return num_sg;
 	return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC);
 }
 
-- 
2.12.2

[toc] | [next] | [standalone]


#1638146

From"Jason A. Donenfeld" <Jason@zx2c4.com>
Date2017-05-09 16:20 +0200
Message-ID<tFe9A-2OU-17@gated-at.bofh.it>
In reply to#1638130
On Tue, May 9, 2017 at 3:50 PM, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>                 num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1;

(The next submission of this will take into account this + 1 here.
https://git.zx2c4.com/linux-dev/log/?h=jd/safe-skb-vec )

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web