From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965601AbdCWQIA (ORCPT ); Thu, 23 Mar 2017 12:08:00 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:60990 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965036AbdCWQH6 (ORCPT ); Thu, 23 Mar 2017 12:07:58 -0400 From: Arnd Bergmann To: Rasesh Mody , Sudarsana Kalluru , Dept-GELinuxNICDev@cavium.com Cc: Arnd Bergmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] bna: avoid writing uninitialized data into hw registers Date: Thu, 23 Mar 2017 17:07:26 +0100 Message-Id: <20170323160734.2029105-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:nCjiITYUEWGCNFfKcVsMwWMtsrbrlpy/nTJwkw2EVz3GX2PxQK7 03APoDJX/S03KJg1J1j5hbOC+ja+FsJWRAOfcduS1jaWRwUipfGs00cKOcr1v295nILsd1K dJYzK3C9SvoC+Yrz0bPgSO1mKGAnHbyACnVlN3qdN8wsfMl+UdpC4JETGcEreiAnVUbtPlG jdUCO3RM9ibV1xcBOYEqg== X-UI-Out-Filterresults: notjunk:1;V01:K0:Yah3bcDAu7w=:3bKn98rXOO0Un9bllmXMcs sE78d73Z7y8Ezr1GNJIYys066Z01uoxbYaGPHZPFI/7uC2rQd9e1tGIcHSBkD6x6dLDgbll1L JZaAiiKgk/FGrp71u95n7pyBeSwiqUqpl0WrTX7srm+GipInMV0VLd/2CbAud1TXrF1ozLtNi cSSLT8HvS/nYcYY74Iuvne6xpMwYNxmPsMql+y1W9RcS7wguhO5uIb4e88eLPx7jRhAzfOb/M 1vAL1Mfjs26mQQL0Ngl2famdaLxUl0eejdV8+ndIbh/uhHY1FDUuSn3d6Nx/U8/CfeU+dmJKQ pxYB9KQBodgbVtYqagMXUoGE6QYOV0QY70HzdhS1gYoBUDk+uVOiAeFX/1bqs+KufrPiVPDFv 9msio9lAPsGxP7HDG2Fpb6E1xq6AlgkeMQkxFIIZ63mKuA3k1gxjDffJpqGWUhSttBnbdzvFw +TIZ3PmOZLtsm/8owmiD73i0ztrp/JN/ZxlxgYkTp8uJCYDdDPEA2DomDqTs7rL0Z6XC4RlV9 JIbK5atR+lS6mZfmcVXVYxo43o3TRfySPHCuZtQdM3TECPe0/gFuRqCditG9zZw9M2rmoRKZs saIa+wPQDDtgH/6bR/9ukXrK6mX7+EQrC0glfeFbGrz4FuiObbwCZNlLMSwiBzPsdwq6dlZ/s tDtJzsWn9vBgO9wnvHltc4by75LaWjdu2UgwU+OiTyPhfRdxv3BVfi6BJf6BCiikgY50= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The latest gcc-7 snapshot warns about bfa_ioc_send_enable/bfa_ioc_send_disable writing undefined values into the hardware registers: drivers/net/ethernet/brocade/bna/bfa_ioc.c: In function 'bfa_iocpf_sm_disabling_entry': arch/arm/include/asm/io.h:109:22: error: '*((void *)&disable_req+4)' is used uninitialized in this function [-Werror=uninitialized] arch/arm/include/asm/io.h:109:22: error: '*((void *)&disable_req+8)' is used uninitialized in this function [-Werror=uninitialized] The two functions look like they should do the same thing, but only one of them initializes the time stamp and clscode field. The fact that we only get a warning for one of the two functions seems to be arbitrary, based on the inlining decisions in the compiler. To address this, I'm making both functions do the same thing: - set the clscode from the ioc structure in both - set the time stamp from ktime_get_real_seconds (which also avoids the signed-integer overflow in 2038 and extends the well-defined behavior until 2106). - zero-fill the reserved field Fixes: 8b230ed8ec96 ("bna: Brocade 10Gb Ethernet device driver") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/brocade/bna/bfa_ioc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c b/drivers/net/ethernet/brocade/bna/bfa_ioc.c index 9e59663a6ead..0f6811860ad5 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c +++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c @@ -1930,13 +1930,13 @@ static void bfa_ioc_send_enable(struct bfa_ioc *ioc) { struct bfi_ioc_ctrl_req enable_req; - struct timeval tv; bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ, bfa_ioc_portid(ioc)); enable_req.clscode = htons(ioc->clscode); - do_gettimeofday(&tv); - enable_req.tv_sec = ntohl(tv.tv_sec); + enable_req.rsvd = htons(0); + /* overflow in 2106 */ + enable_req.tv_sec = ntohl(ktime_get_real_seconds()); bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req)); } @@ -1947,6 +1947,10 @@ bfa_ioc_send_disable(struct bfa_ioc *ioc) bfi_h2i_set(disable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_DISABLE_REQ, bfa_ioc_portid(ioc)); + disable_req.clscode = htons(ioc->clscode); + disable_req.rsvd = htons(0); + /* overflow in 2106 */ + disable_req.tv_sec = ntohl(ktime_get_real_seconds()); bfa_ioc_mbox_send(ioc, &disable_req, sizeof(struct bfi_ioc_ctrl_req)); } -- 2.9.0