stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org
Cc: Nathan Chancellor <natechancellor@gmail.com>,
	"Jason A . Donenfeld" <Jason@zx2c4.com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	"David S . Miller" <davem@davemloft.net>
Subject: [PATCH 4.4 3/3] virtio_net: check return value of skb_to_sgvec in one more location
Date: Mon,  9 Apr 2018 18:21:47 -0700	[thread overview]
Message-ID: <20180410012150.6573-7-natechancellor@gmail.com> (raw)
In-Reply-To: <20180410012150.6573-1-natechancellor@gmail.com>

Kernels that do not have f6b10209b90d ("virtio-net: switch to use
build_skb() for small buffer") will have an extra call to skb_to_sgvec
that is not handled by e2fcad58fd23 ("virtio_net: check return value of
skb_to_sgvec always"). Since the former does not appear to be stable
material, just fix the call up directly.

Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

Greg, if you feel this should be squashed into the previous commit, by
all means, feel free. I am not entirely sure if the dev_kfree_skb is
necessary here, I was hoping to get some review.

---
 drivers/net/virtio_net.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index bb2bae522f67..d01285250204 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -556,7 +556,12 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
 	hdr = skb_vnet_hdr(skb);
 	sg_init_table(rq->sg, 2);
 	sg_set_buf(rq->sg, hdr, vi->hdr_len);
-	skb_to_sgvec(skb, rq->sg + 1, 0, skb->len);
+
+	err = skb_to_sgvec(skb, rq->sg + 1, 0, skb->len);
+	if (unlikely(err < 0)) {
+		dev_kfree_skb(skb);
+		return err;
+	}
 
 	err = virtqueue_add_inbuf(rq->vq, rq->sg, 2, skb, gfp);
 	if (err < 0)
-- 
2.17.0

  parent reply	other threads:[~2018-04-10  1:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10  1:21 Further fixes for 48a1df65334b Nathan Chancellor
2018-04-10  1:21 ` [PATCH 3.18 1/3] rxrpc: check return value of skb_to_sgvec always Nathan Chancellor
2018-04-10  1:21 ` [PATCH 3.18 2/3] virtio_net: " Nathan Chancellor
2018-04-10  1:21 ` [PATCH 3.18 3/3] virtio_net: check return value of skb_to_sgvec in one more location Nathan Chancellor
2018-04-10 12:34   ` Patch "virtio_net: check return value of skb_to_sgvec in one more location" has been added to the 3.18-stable tree gregkh
2018-04-10  1:21 ` [PATCH 4.4 1/3] rxrpc: check return value of skb_to_sgvec always Nathan Chancellor
2018-04-10  1:21 ` [PATCH 4.4 2/3] virtio_net: " Nathan Chancellor
2018-04-10  1:21 ` Nathan Chancellor [this message]
2018-04-10  9:07   ` Patch "virtio_net: check return value of skb_to_sgvec in one more location" has been added to the 4.4-stable tree gregkh
2018-04-10  1:21 ` [PATCH 4.9 1/3] rxrpc: check return value of skb_to_sgvec always Nathan Chancellor
2018-04-10  1:21 ` [PATCH 4.9 2/3] virtio_net: " Nathan Chancellor
2018-04-10  1:21 ` [PATCH 4.9 3/3] virtio_net: check return value of skb_to_sgvec in one more location Nathan Chancellor
2018-04-10  6:35   ` Greg Kroah-Hartman
2018-04-10  7:11     ` Greg Kroah-Hartman
2018-04-10  7:12   ` Patch "virtio_net: check return value of skb_to_sgvec in one more location" has been added to the 4.9-stable tree gregkh
2018-04-10 12:53 ` Further fixes for 48a1df65334b Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180410012150.6573-7-natechancellor@gmail.com \
    --to=natechancellor@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).