[PATCH] virtio_net: memset scatterlist before using

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
--

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,


--
To unsubscribe from this list: send the line "unsubscribe linux-next" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux