Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp596163ybt; Fri, 19 Jun 2020 09:00:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxolJSFW+s8+dUHn76MUBOH86Mx9Q49+TGLpZSh/Kd/cko+piXpfonMn74Dbd2rVkzAUFDO X-Received: by 2002:a17:906:799:: with SMTP id l25mr4247781ejc.234.1592582416999; Fri, 19 Jun 2020 09:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592582416; cv=none; d=google.com; s=arc-20160816; b=hgjbsMUhzJoAZgcgRlTZRQKbdQRgBR7t35SVNNuDrQBQzIlbjnHRoURyp66mLqgSss 4eMYritewELecDqg1VmGl3/L6FtqX0Wbih+o59HzgKyFvW7sCaYgHCg4L4KOGzjpWO0W RGLo/rM0xfPFmcygxWzqXhzAFnvHuWHz6v/3QggW5siESVgkR5C1LFkU9conXrSzieAn ahpZ7zvjd0xeoSm/CDNd+nrMqEELdPCk6vF9EelBob4W0la3Ab0BqnxtoQYetFXNFzuF kE9QCnlfWm73WQ9pW99RdkGKYwbR4aG61AO+uxNYWD3P+uxFJ1gP0sfPS58s2GwQzJkA TqfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GR1UrV/tJAaUP6zo5a2daZFfLaAw9euWlkG8qgpI6qE=; b=AhveHQNFdFjf3Zj/3JdBxEHhR9Y0alkESQ3ZpzC0t1i8PRfdMa8PMucZGuLgNv85GF h+D6ObaqIE3Tcxwzj6vWDIJWQGp4VqX/pY/jfx1koMF6tugaRXjOWwa6c8Qes+Wc4Ee/ 1Vsv/fWjcGcrTy3u7lzTdGw3zU++a0v7MJO9hFOmVwgkM/kk+YxxXjxa7tRdjj6mr8Ks 8hdF0cqJb4djwuQOhT8LvjShlflpZryjA5OuWk253l1gKlmI5+ZeYjK7LWKbbPzft21E waE0lV6rCJIxnw9P11yj222sfOUpO2ZVnVwhBXymQINQpM50A2Ge4R8RgFId0gX41+y+ TxKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SVSS48iR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yd12si3985278ejb.237.2020.06.19.08.59.55; Fri, 19 Jun 2020 09:00:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SVSS48iR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405367AbgFSP5Q (ORCPT + 99 others); Fri, 19 Jun 2020 11:57:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:51560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390560AbgFSPUZ (ORCPT ); Fri, 19 Jun 2020 11:20:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A135820771; Fri, 19 Jun 2020 15:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580024; bh=74wKcSC/1/uY7MLx3rVRs5Efvh1k7Obe/4c2cXj8RbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVSS48iR8o5gteYU+s/04b+nXJasyYT61zb5RomzVMz0sETCX2UMPDoO0QG5YQmOa t5phOCq2S7wMHlsHtwvAHCcmCVO5a53vviDvGxOGP0g0x74DpFEE9zKbKnXGDNYP7w FNGt/6chFcnr5nuEp6+SkHDriFDhQ3kv8dROKT8U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Aaron Brown , Jeff Kirsher , Sasha Levin Subject: [PATCH 5.7 094/376] e1000: Distribute switch variables for initialization Date: Fri, 19 Jun 2020 16:30:12 +0200 Message-Id: <20200619141714.789670361@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook [ Upstream commit a34c7f5156654ebaf7eaace102938be7ff7036cb ] Variables declared in a switch statement before any case statements cannot be automatically initialized with compiler instrumentation (as they are not part of any execution flow). With GCC's proposed automatic stack variable initialization feature, this triggers a warning (and they don't get initialized). Clang's automatic stack variable initialization (via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also doesn't initialize such variables[1]. Note that these warnings (or silent skipping) happen before the dead-store elimination optimization phase, so even when the automatic initializations are later elided in favor of direct initializations, the warnings remain. To avoid these problems, move such variables into the "case" where they're used or lift them up into the main function body. drivers/net/ethernet/intel/e1000/e1000_main.c: In function ‘e1000_xmit_frame’: drivers/net/ethernet/intel/e1000/e1000_main.c:3143:18: warning: statement will never be executed [-Wswitch-unreachable] 3143 | unsigned int pull_size; | ^~~~~~~~~ [1] https://bugs.llvm.org/show_bug.cgi?id=44916 Signed-off-by: Kees Cook Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/e1000/e1000_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 0d51cbc88028..05bc6e216bca 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -3136,8 +3136,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); if (skb->data_len && hdr_len == len) { switch (hw->mac_type) { + case e1000_82544: { unsigned int pull_size; - case e1000_82544: + /* Make sure we have room to chop off 4 bytes, * and that the end alignment will work out to * this hardware's requirements @@ -3158,6 +3159,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, } len = skb_headlen(skb); break; + } default: /* do nothing */ break; -- 2.25.1