Subject: Re: [PATCH] virtio_net: memset scatterlist before using

From: Rusty Russell <[email-masked]>
Date: Sun, 26 Apr 2009 22:28:08 +0930

On Sat, 25 Apr 2009 12:07:03 am Alex Williamson wrote:
> 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.

This will break CONFIG_DEBUG_SG=y.

Why not sg_init_one?  This is what it's for...

Thanks,
Rusty