From patchwork Thu May 12 20:36:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 95359 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 164D2B6F0C for ; Fri, 13 May 2011 06:36:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758624Ab1ELUgR (ORCPT ); Thu, 12 May 2011 16:36:17 -0400 Received: from mail.perches.com ([173.55.12.10]:1573 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758620Ab1ELUgP (ORCPT ); Thu, 12 May 2011 16:36:15 -0400 Received: from Joe-Laptop.home (unknown [192.168.1.162]) by mail.perches.com (Postfix) with ESMTP id AF46424368; Thu, 12 May 2011 13:36:10 -0700 (PDT) From: Joe Perches To: linux-kernel@vger.kernel.org Cc: "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH] net: af_packet: Don't initialize vnet_hdr Date: Thu, 12 May 2011 13:36:10 -0700 Message-Id: <18a010357eb63dfd50751c5eb529f6261cf90ecd.1305232529.git.joe@perches.com> X-Mailer: git-send-email 1.7.5.rc3.dirty Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Save a memset, initialize only the portion necessary. packet_snd either gets this structure completely from memcpy_fromiovec or uses only the hdr_len set to 0, so don't always initialize the structure to 0. Signed-off-by: Joe Perches --- net/packet/af_packet.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 549527b..ac88df9 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1123,7 +1123,7 @@ static int packet_snd(struct socket *sock, __be16 proto; unsigned char *addr; int ifindex, err, reserve = 0; - struct virtio_net_hdr vnet_hdr = { 0 }; + struct virtio_net_hdr vnet_hdr; int offset = 0; int vnet_hdr_len; struct packet_sock *po = pkt_sk(sk); @@ -1206,7 +1206,9 @@ static int packet_snd(struct socket *sock, goto out_unlock; } - } + } else + vnet_hdr.hdr_len = 0; + err = -EMSGSIZE; if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN))