From patchwork Fri Mar 24 22:02:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9644077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 179946020B for ; Fri, 24 Mar 2017 22:04:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08BC726530 for ; Fri, 24 Mar 2017 22:04:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F197926E69; Fri, 24 Mar 2017 22:04:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D57726530 for ; Fri, 24 Mar 2017 22:04:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753936AbdCXWDp (ORCPT ); Fri, 24 Mar 2017 18:03:45 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:54782 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753140AbdCXWDi (ORCPT ); Fri, 24 Mar 2017 18:03:38 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MMWCs-1cols02nQU-008HQo; Fri, 24 Mar 2017 23:03:10 +0100 From: Arnd Bergmann To: "David S . Miller" , Doug Ledford Cc: Arnd Bergmann , Lijun Ou , "Wei Hu(Xavier)" , Daode Huang , Kejian Yan , Qianqian Xie , Wei Yongjun , Yisen Zhuang , Salil Mehta , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [RESEND PATCH 1/3] net: hns: fix uninitialized data use Date: Fri, 24 Mar 2017 23:02:49 +0100 Message-Id: <20170324220250.2193128-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170324220250.2193128-1-arnd@arndb.de> References: <20170324220250.2193128-1-arnd@arndb.de> X-Provags-ID: V03:K0:Fqck4FSIX5FxmCn55wKuah6y1qtBLaNC/FJ30E8yqSNoTpMV73u valhidDImUJFOA5zvqyg4CXoeDkx5osSEJObB2HuwcOMVTgwvNVhA2qEDY7npZO99NN8T87 /jKbjoZ/kicbzc1p83vPsCMtZrH+xzgdVOgYgAPn4Fv49v5yZU0LhPulBgAExyFT53dvizw WL/59CbE9ef4JpOOrt/5w== X-UI-Out-Filterresults: notjunk:1; V01:K0:otPNvUhuvhs=:tKVSjxxhEoHpULOru415a0 9Cxx85b9/n921FrlwQw686D22wyWg0mgWg8GE7f5UVQaODAxyWb/c+LAWM3z7dxWtSg+iCl+J i0ursPXWgA2AOJ5bbehtq4wrixDWhLnMBp5hy4DAgqrW0N07bA40+ZDjv+pY3RbtVwJLdGDJ/ xnRN34TEnu0lxUkawVu+t5kLlLWb1w1J8vZRa3max3nOLUmOMVhutxEYblDIL31j38wzisN9Y WmZG5XH0DYo45ZRUZXRKp31pWR32NebpDUrxAF4SoU77OVNm6aiAxAl4n7h2SgKEmWIkDcv7P sctlf1k2Lh6QKG+2C5OCLLyrNtKmZLWcxiW9z2U1xwaBv9mVJLUBd5L6YdMZ1p0r4uJL6SWvJ cMUUn1bmkdRQ5X7Pf07onycEtEv5YAKQWQmPc1BTd/oSQL3ZPjCcTB6w/4fzgVmLG0srMqA32 DlqQWrY+VgMUV48AmgqUHiYg36Zs7NdXN7qmfUt0jSMhQ6/24iWdkNpuMbIhGgqeFsLIDKbJ8 BQmxV1ij8se/SSfpuMLrzr/5b5Lsr6yU3U80tOr4tKy3UhG/gDppwqB8xH2RT/73fqspW/MK3 c3j4HrVW93PNyCOMlwd90nh8rYXifc2jNtbhH1nRXFxREEj/81Tn5+wB+lCBKT5RLeXJfLl0E HQD6IYqXqWB8udQ5CY8jz9IhyWYhVcruLMriQzGk6sr6WgFMcL26LiYGqWCdwjrxgin8= Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When dev_dbg() is enabled, we print uninitialized data, as gcc-7.0.1 now points out: ethernet/hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_promisc_tcam': ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.low.val' may be used uninitialized in this function [-Werror=maybe-uninitialized] ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.high.val' may be used uninitialized in this function [-Werror=maybe-uninitialized] We also pass the data into hns_dsaf_tcam_mc_cfg(), which might later use it (not sure about that), so it seems safer to just always initialize the tbl_tcam_data structure. Fixes: 1f5fa2dd1cfa ("net: hns: fix for promisc mode in HNS driver") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c index 90dbda792614..cd93657abe87 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c @@ -2924,10 +2924,11 @@ void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev, /* find the tcam entry index for promisc */ entry_index = dsaf_promisc_tcam_entry(port); + memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data)); + memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask)); + /* config key mask */ if (enable) { - memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data)); - memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask)); dsaf_set_field(tbl_tcam_data.low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M, DSAF_TBL_TCAM_KEY_PORT_S, port);