From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E48E7C433E2 for ; Wed, 3 Jun 2020 23:32:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8F4482077D for ; Wed, 3 Jun 2020 23:32:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="oLglV2NF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F4482077D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 68DD1280093; Wed, 3 Jun 2020 19:32:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 572BA280094; Wed, 3 Jun 2020 19:32:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41128280093; Wed, 3 Jun 2020 19:32:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 0FAE2280094 for ; Wed, 3 Jun 2020 19:32:18 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C68222DFA for ; Wed, 3 Jun 2020 23:32:17 +0000 (UTC) X-FDA: 76889501514.08.mass03_13fe296caa94f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id A7DD51819E76B for ; Wed, 3 Jun 2020 23:32:17 +0000 (UTC) X-HE-Tag: mass03_13fe296caa94f X-Filterd-Recvd-Size: 5357 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 3 Jun 2020 23:32:17 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id b16so2466750pfi.13 for ; Wed, 03 Jun 2020 16:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z79mte9tXyXKJqcwg2to640Wx2Eg5qdbPrxISPqquNw=; b=oLglV2NFfWcYacYEWd+TtydM20VTgwWe1gq21Fthy+SgsdpnjxFQ4Ga6u1Qy8QOuhq 1+c/7ALdx0vchA5G8glRAPu5IZRrjlpO6MXFnSd1l4xnQge821R1YpyaThNWtUXXRQkZ BdWautw1YEzJ6ceFFpGiknqeHem+S3a8xUfFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z79mte9tXyXKJqcwg2to640Wx2Eg5qdbPrxISPqquNw=; b=ngawk/9T01a+U1r83b2ZDxeEpjnun6C1uP7xR3Nh3PEcEhSOnaBlBSOYlB7B5LsaQc KvD+G/C+0XyQz5KQWBzHyXCHiEfC4sTyJuM4anh4QaImJhwU2/iE/yo1YeH6fsUP6uDV AKK2VFruvUiT8hVk3oZD/feQtIAIDs4thxrce7wM3DFLhc0GwYGlv5yFAV0386bc27Hv ptS4eRRf4ku4uFnRypXXvTed0eZQEbxiY1Ix/FByOn2TGRwmYiisP5u9KAx4gd+xz2u3 8KuFRyxJ2O0qbVYrRqJYt2asZ1NCHRU2rLrknwDiUuvRhw27qFhBqdChASSaZfsse/nv oJZg== X-Gm-Message-State: AOAM533AHBuPfRNhXx6N6FCcUMNGom02Arx+2ambP/XsBLlHrKXXYceS D9Ug66YvlRk5uNR8aCYJO4dF4w== X-Google-Smtp-Source: ABdhPJzEnF0voBtIhVxbXIY3ed6bQ+lYw39TPSGZER6ztQVM7GNLumS6Ixq11iEOXvbkyysEKAiNmA== X-Received: by 2002:aa7:9a93:: with SMTP id w19mr1488633pfi.155.1591227136432; Wed, 03 Jun 2020 16:32:16 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j8sm3442213pjw.11.2020.06.03.16.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 16:32:12 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Linus Torvalds , Miguel Ojeda , Alexander Potapenko , Joe Perches , Andy Whitcroft , x86@kernel.org, drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, b43-dev@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-ide@vger.kernel.org, linux-clk@vger.kernel.org, linux-spi@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com Subject: [PATCH 03/10] b43: Remove uninitialized_var() usage Date: Wed, 3 Jun 2020 16:31:56 -0700 Message-Id: <20200603233203.1695403-4-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200603233203.1695403-1-keescook@chromium.org> References: <20200603233203.1695403-1-keescook@chromium.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A7DD51819E76B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Using uninitialized_var() is dangerous as it papers over real bugs[1] (or can in the future), and suppresses unrelated compiler warnings (e.g. "unused variable"). If the compiler thinks it is uninitialized, either simply initialize the variable or make compiler changes. As a precursor to removing[2] this[3] macro[4], just initialize this variable to NULL, and make the (unreachable!) code do a conditional test. [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.co= m/ [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=3D1TGqCR5vQkCzWJ0QxK6Cern= OU6eedsudAixw@mail.gmail.com/ [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz= 9knmPuXhOeg@mail.gmail.com/ [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=3DyVJu65TpLg= N_ybYNv0VEOKA@mail.gmail.com/ Signed-off-by: Kees Cook --- drivers/net/wireless/broadcom/b43/phy_n.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wire= less/broadcom/b43/phy_n.c index d3c001fa8eb4..88cdcea10d61 100644 --- a/drivers/net/wireless/broadcom/b43/phy_n.c +++ b/drivers/net/wireless/broadcom/b43/phy_n.c @@ -4222,7 +4222,7 @@ static void b43_nphy_tx_gain_table_upload(struct b4= 3_wldev *dev) u32 rfpwr_offset; u8 pga_gain, pad_gain; int i; - const s16 *uninitialized_var(rf_pwr_offset_table); + const s16 *rf_pwr_offset_table =3D NULL; =20 table =3D b43_nphy_get_tx_gain_table(dev); if (!table) @@ -4256,9 +4256,13 @@ static void b43_nphy_tx_gain_table_upload(struct b= 43_wldev *dev) pga_gain =3D (table[i] >> 24) & 0xf; pad_gain =3D (table[i] >> 19) & 0x1f; if (b43_current_band(dev->wl) =3D=3D NL80211_BAND_2GHZ) - rfpwr_offset =3D rf_pwr_offset_table[pad_gain]; + rfpwr_offset =3D rf_pwr_offset_table + ? rf_pwr_offset_table[pad_gain] + : 0; else - rfpwr_offset =3D rf_pwr_offset_table[pga_gain]; + rfpwr_offset =3D rf_pwr_offset_table + ? rf_pwr_offset_table[pga_gain] + : 0; } else { pga_gain =3D (table[i] >> 24) & 0xF; if (b43_current_band(dev->wl) =3D=3D NL80211_BAND_2GHZ) --=20 2.25.1