Netdev List
 help / color / mirror / Atom feed
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
To: netdev@vger.kernel.org
Cc: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Subject: [PATCH] virtio_net: fix the potential NULL pointer in xmit_skb()
Date: Fri, 14 Feb 2014 12:00:08 +0800	[thread overview]
Message-ID: <1392350408-3811-1-git-send-email-wuzhy@linux.vnet.ibm.com> (raw)

The pointer hdr isn't assigned before hdr->mhdr and hdr->hdr
are used, so it could be one invalid pointer.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 drivers/net/virtio_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d75f8ed..bf6397f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -807,9 +807,9 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 
 	pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest);
 	if (vi->mergeable_rx_bufs)
-		hdr_len = sizeof hdr->mhdr;
+		hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
 	else
-		hdr_len = sizeof hdr->hdr;
+		hdr_len = sizeof(struct virtio_net_hdr);
 
 	can_push = vi->any_header_sg &&
 		!((unsigned long)skb->data & (__alignof__(*hdr) - 1)) &&
-- 
1.8.4.2

             reply	other threads:[~2014-02-14  4:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14  4:00 Zhi Yong Wu [this message]
2014-02-14  5:12 ` [PATCH] virtio_net: fix the potential NULL pointer in xmit_skb() David Miller
2014-02-14  5:25   ` Zhi Yong Wu

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=1392350408-3811-1-git-send-email-wuzhy@linux.vnet.ibm.com \
    --to=wuzhy@linux.vnet.ibm.com \
    --cc=netdev@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