Received: by 10.223.185.116 with SMTP id b49csp1030922wrg; Fri, 23 Feb 2018 10:38:57 -0800 (PST) X-Google-Smtp-Source: AH8x225FqDRKKLu/kFE+Dx8YRg2Qd6t4BPv0RZyAkrI3ecA9lqf+Qis5YjJNuhKpJ94SXLh/zDeb X-Received: by 2002:a17:902:5a1:: with SMTP id f30-v6mr2551494plf.124.1519411137675; Fri, 23 Feb 2018 10:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411137; cv=none; d=google.com; s=arc-20160816; b=cGXJUcJqujRkYKjKty1OpY/Q58QOnoH/g1KEq42HT+ByZqaz6/2vo4JM9u8UA26cQk 7dMtmbrF4aAGYV8GPJeKLXW4OUHxFjTH4lVRp8Ak1wro3NwhfKieI/ApkuOEOeSPz5rH 0Y7d/kNH4edqybBPnKF1p4uqfe1dicEjovJOLFZcd2MnVDPfkc0jPGryJfEkbm3ZhOpJ hNq0mcQVKTautD/wzjAPqyfZpkJ5a8cOppSg+D3bLZcdlKogOJW0bJzqPAi1M3Q5gW5R K+qYUDg+VXprgSk0LwXe0ILHhrvDvN6KY8g0k5/79mMBUcM8NpzqmFG5SRZTQcOtc0H/ E21A== 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=AZavuPWPLj2gLqu+2a1aKJ/ffiJcVGBKxAiTdpfI1Cg=; b=bifArd1+CQMCP74EpwCiB1sybVSj4TleTzc+viQ8CPdLtWP4Nihk7WfjRJy2Msy2yu btEr69kjZvNn0dY27uhBzlhpP8FMc8VTKzsQXilQrv0uVTSrFZ6dwpf9p6Mdx9RO2mCQ qAjoYwWZmXK+SuMJ57WRei7NS/gid7+7a6KaqM+lQU0qShXJnx7xp5WT7MsGaIxpl5E4 hKDDRg46jbn8pj9z5mFJ8qafmAG9oYfeosNZ8FwpNW8D8tYje4p57nwp8zGirDtUO+ka jPSKiopvZP5UGksqJKf1Ce5r56iPPSa0Zoe2Tyjo6CfPfo6LYxss4RPq6g8ziI51quRX xn0g== 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 j74si2195889pfk.202.2018.02.23.10.38.42; Fri, 23 Feb 2018 10:38:57 -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 S1754284AbeBWSiG (ORCPT + 99 others); Fri, 23 Feb 2018 13:38:06 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38860 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932298AbeBWSiC (ORCPT ); Fri, 23 Feb 2018 13:38:02 -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 87D7CFA7; Fri, 23 Feb 2018 18:38:01 +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.4 077/193] scsi: advansys: fix uninitialized data access Date: Fri, 23 Feb 2018 19:25:10 +0100 Message-Id: <20180223170338.094710484@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@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.4-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,