virtio_net: Do not clear memory for struct virtio_net_hdr twice.
authorJarno Rajahalme <jarno@ovn.org>
Fri, 18 Nov 2016 23:40:40 +0000 (15:40 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 19 Nov 2016 15:37:03 +0000 (10:37 -0500)
virtio_net_hdr_from_skb() clears the memory for the header, so there
is no point for the callers to do the same.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c
include/linux/virtio_net.h
net/packet/af_packet.c

index 3b8d8cc6d2ea0fbab92e2084503ac0bc81b95029..64e694c68d99a86932c5383a2332be3548e6756c 100644 (file)
@@ -1360,8 +1360,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
        }
 
        if (vnet_hdr_sz) {
-               struct virtio_net_hdr gso = { 0 }; /* no info leak */
-               int ret;
+               struct virtio_net_hdr gso;
 
                if (iov_iter_count(iter) < vnet_hdr_sz)
                        return -EINVAL;
index 74f1e336350656df078ee1f89fd8008aff27f587..66204007d7ac32f1f32068c1f46fc1a033e6953f 100644 (file)
@@ -58,7 +58,7 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
                                          struct virtio_net_hdr *hdr,
                                          bool little_endian)
 {
-       memset(hdr, 0, sizeof(*hdr));
+       memset(hdr, 0, sizeof(*hdr));   /* no info leak */
 
        if (skb_is_gso(skb)) {
                struct skb_shared_info *sinfo = skb_shinfo(skb);
index d2238b204691b8e4f2e3acb9bc167b553ba32d50..abe6c0b6683c7cc205e864965cd34508bbb18019 100644 (file)
@@ -1970,8 +1970,6 @@ static unsigned int run_filter(struct sk_buff *skb,
 static int __packet_rcv_vnet(const struct sk_buff *skb,
                             struct virtio_net_hdr *vnet_hdr)
 {
-       *vnet_hdr = (const struct virtio_net_hdr) { 0 };
-
        if (virtio_net_hdr_from_skb(skb, vnet_hdr, vio_le()))
                BUG();