Received: by 10.223.185.116 with SMTP id b49csp1039217wrg; Fri, 23 Feb 2018 10:48:37 -0800 (PST) X-Google-Smtp-Source: AH8x224OIX+VCtAqp5dD7TRnSHu1XJrrw51gCsJ+4iM/2vY4cr1gjN1S1beMDqoiMDrbA1tI2RTH X-Received: by 10.99.129.66 with SMTP id t63mr2113274pgd.376.1519411717139; Fri, 23 Feb 2018 10:48:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411717; cv=none; d=google.com; s=arc-20160816; b=Z/ld1Xh0skZvWMFI63I+UNuONk7kD8c6jmYdMsCbhX8CamdTPGEV5r+5MmYFy1NKet 3Jum7Omyj4R86033UYSZmx1S+pdzfsn0FbHULU9OKRmFOlr9I/ucrMSo3lmv01GchvEo jhs7+pTjNa1OAtxwWc8LfphcVabzq/ZAjKmV1YIueUgktb2yxVf93YY9jfYsYWe2hPl1 1yw7w9m2VpcS6NdOaUfUKRwfJDay10TMxC2E8WiCpgrJBho4Ld9/xjaXkSPWr+8k+Gtr O2CWaSXxaBGQyLiH+8t4yFYNOzmwhBn6IeO1vKGUiooV9hs+1UAQdhZlk1fBNrJkuevJ DM0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=V6Ao1EbYFCZl08OWcpdgIZxin3P1SWiimrTsR37QGaA=; b=lI2O/MLQx/bw08595/45K+05wFxALopmHeCa7QmDwK9yGTYq9UU18w4sUnWMq1sA5Y kYssHqcYU0E43WwULhX5lJjyLS0gyAJ/L0/k8pdzdhgtSynDSfD/tp/yzKR7/ogCrSeq YGgmhq4QeUoTe4N/dONL9LLFF3psXnirGQqH7OHvJkprkjfMJXQ0ByHRcK9iWRwr4NI6 /caLqRLCKvLEW1oUyxgQKWC7/xje/7uUhVQr+0S+WfXf5OOrsqX/CBTjOWJkKo3fljuG HQs42tAsJ0kjQLSx0EefGEpKZUlYroTh8on5BuBQUuORWrxr+MRVuNBUCeUCnkb0kCqd /8nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si1826052pgv.79.2018.02.23.10.48.22; Fri, 23 Feb 2018 10:48:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934194AbeBWSrf (ORCPT + 99 others); Fri, 23 Feb 2018 13:47:35 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44580 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933859AbeBWSrb (ORCPT ); Fri, 23 Feb 2018 13:47:31 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 96F55FDC; Fri, 23 Feb 2018 18:47:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "Martin K. Petersen" Subject: [PATCH 4.9 115/145] scsi: advansys: fix uninitialized data access Date: Fri, 23 Feb 2018 19:27:01 +0100 Message-Id: <20180223170739.696833771@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit 44a5b977128c0ffff0654392b40f4c2ce72a619b upstream. gcc-7.0.1 now warns about a previously unnoticed access of uninitialized struct members: drivers/scsi/advansys.c: In function 'AscMsgOutSDTR': drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+5)' may be used uninitialized in this function [-Werror=maybe-uninitialized] ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); ^ drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+7)' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+5)' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+7)' may be used uninitialized in this function [-Werror=maybe-uninitialized] The code has existed in this exact form at least since v2.6.12, and the warning seems correct. This uses named initializers to ensure we initialize all members of the structure. Signed-off-by: Arnd Bergmann Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/advansys.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -6291,18 +6291,17 @@ static uchar AscGetSynPeriodIndex(ASC_DV static uchar AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset) { - EXT_MSG sdtr_buf; - uchar sdtr_period_index; - PortAddr iop_base; - - iop_base = asc_dvc->iop_base; - sdtr_buf.msg_type = EXTENDED_MESSAGE; - sdtr_buf.msg_len = MS_SDTR_LEN; - sdtr_buf.msg_req = EXTENDED_SDTR; - sdtr_buf.xfer_period = sdtr_period; + PortAddr iop_base = asc_dvc->iop_base; + uchar sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period); + EXT_MSG sdtr_buf = { + .msg_type = EXTENDED_MESSAGE, + .msg_len = MS_SDTR_LEN, + .msg_req = EXTENDED_SDTR, + .xfer_period = sdtr_period, + .req_ack_offset = sdtr_offset, + }; sdtr_offset &= ASC_SYN_MAX_OFFSET; - sdtr_buf.req_ack_offset = sdtr_offset; - sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period); + if (sdtr_period_index <= asc_dvc->max_sdtr_index) { AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG, (uchar *)&sdtr_buf,