linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@hp.com>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
	linux-next@vger.kernel.org, Rusty Russell <rusty@rustcorp.com.au>,
	LKML.netdev@vger.kernel.org
Subject: [PATCH] virtio_net: memset scatterlist before using
Date: Fri, 24 Apr 2009 08:37:03 -0600	[thread overview]
Message-ID: <1240583823.16438.14.camel@lappy> (raw)
In-Reply-To: <20090423163847.200f227e.sfr@canb.auug.org.au>

A powerpc gcc-4.4 build generates the following warnings:

drivers/net/virtio_net.c: In function 'virnet_vlan_rx_add_vid':
include/linux/scatterlist.h:57: warning: 'sg' is used uninitialized in this function
drivers/net/virtio_net.c:746: note: 'sg' was declared here
drivers/net/virtio_net.c: In function 'virnet_vlan_rx_kill_vid':
include/linux/scatterlist.h:57: warning: 'sg' is used uninitialized in this function
drivers/net/virtio_net.c:758: note: 'sg' was declared here

We need to clear the scatterlist before using it.  This sg entry will
get copied into another scatterlist before it's used, so memset it
rather than using sg_init_table or sg_init_one to avoid a bogus end
marker.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
--

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0718558..be1a9fe 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -745,6 +745,7 @@ static void virnet_vlan_rx_add_vid(struct net_device *dev, u16 vid)
 	struct virtnet_info *vi = netdev_priv(dev);
 	struct scatterlist sg;
 
+	memset(&sg, 0, sizeof(sg));
 	sg_set_buf(&sg, &vid, sizeof(vid));
 
 	if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
@@ -757,6 +758,7 @@ static void virnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
 	struct virtnet_info *vi = netdev_priv(dev);
 	struct scatterlist sg;
 
+	memset(&sg, 0, sizeof(sg));
 	sg_set_buf(&sg, &vid, sizeof(vid));
 
 	if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,

  parent reply	other threads:[~2009-04-24 14:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090423163847.200f227e.sfr@canb.auug.org.au>
2009-04-23  7:24 ` linux-next: upstream tree build warnings David Miller
2009-04-23 11:55   ` Stephen Rothwell
2009-04-23 12:51     ` Stephen Rothwell
2009-04-23 16:46       ` Alex Williamson
2009-04-26 12:23   ` Rusty Russell
2009-04-27  6:32     ` David Miller
2009-04-24 14:37 ` Alex Williamson [this message]
2009-04-26 12:58   ` [PATCH] virtio_net: memset scatterlist before using Rusty Russell
2009-04-27  6:30     ` David Miller
2009-04-27 15:50       ` [PATCH] virtio_net: Cleanup command queue scatterlist usage Alex Williamson
2009-04-28  9:30         ` David Miller
2009-05-01 22:33         ` David Miller
2009-05-01 22:43           ` Alex Williamson
2009-05-01 22:52             ` David Miller
2009-05-02  3:27           ` Alex Williamson
2009-05-02  4:26             ` David Miller
2009-05-05  3:21         ` Rusty Russell

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=1240583823.16438.14.camel@lappy \
    --to=alex.williamson@hp.com \
    --cc=LKML.netdev@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-next@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sfr@canb.auug.org.au \
    /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).