Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3730079imm; Mon, 18 Jun 2018 03:07:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJeYHpogLRa68+cYq7aRFYbSvjIXSW+FOqcKHElj1ZAWWKm8EuMYo0bGSw5GuUdnlnsZ52D X-Received: by 2002:a17:902:9f81:: with SMTP id g1-v6mr12158688plq.304.1529316455740; Mon, 18 Jun 2018 03:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529316455; cv=none; d=google.com; s=arc-20160816; b=vnGnyDQ9z6CI4vFDCsCmCsCeDb2Te05MoWGjUqcWEqCEld0Su2ottJL7rW1tFPtr1k vZ70BbiH/6clNSl7OBuq4/y4+ELnDuqHTIPIpTwcLiSU4Blf9iOmOTWo+C9X1MwIqCEN 4c9k58RjdSjoBUXdRCZWdkI/KZ1Vs8WRgPU9n7WjzV4kR0biedRCfhWCecdENk7hqyni rSoeIoNuyd4bzzueJCwxDliYOsZ3CxKHO1DeNbCQySbEj9TWRZnC3ooaQBbe8bA3kJDw NAgql6nPljwBVc3kz7vdpetK8ThfABv52RGARM0qkqoAQxxD85YcsMbRpFBhIg0Ozdmx 7mZg== 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=ZvF6hDx1e4RrknvdZ13oEojs5PpMtFuPJKQP28CpMYw=; b=JBCSiKLvvIw5cu+sNMX1fQc0ld3zt3I7WRUMnSSeZpUimjwCBCIZUCF5BLX7e9+H05 0K8Qhbxozc+Epg+6u8ZYN4vaUHKWQ1joWMPJVYkEAOtdjN6b1HmiIzAuhOPLKAu72wng gkniozEZwSS7vSUQplNxJgzJU4YtVa3JUVVpnZs2/88zDRvIKfFX66SEaA2DIwJWiTWf hvVE4uA+Xxg6Xsf2hc2I/du3DiEoOINxkeQvr9FrDhyqG2gkW66nlXochlFnAsG/ioJ9 sQHd/q0p9PpYDkcZKdJ5mXUbOrLFVFBks+5EYH72l73sq+PmEvj+/NwZJL/7SQkj0/va lJtg== 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 r9-v6si11700885pgf.664.2018.06.18.03.07.22; Mon, 18 Jun 2018 03:07:35 -0700 (PDT) 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 S934952AbeFRIRz (ORCPT + 99 others); Mon, 18 Jun 2018 04:17:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54314 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934358AbeFRIRx (ORCPT ); Mon, 18 Jun 2018 04:17:53 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 68EDDC7A; Mon, 18 Jun 2018 08:17:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.16 066/279] scsi: isci: Fix infinite loop in while loop Date: Mon, 18 Jun 2018 10:10:51 +0200 Message-Id: <20180618080611.559487016@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colin Ian King [ Upstream commit 4bc83b3f272fe8f36450f9c003df49cf07ffe5fd ] In the case when the phy_mask is bitwise anded with the phy_index bit is zero the continue statement currently jumps to the next iteration of the while loop and phy_index is never actually incremented, potentially causing an infinite loop if phy_index is less than SCI_MAX_PHS. Fix this by turning the while loop into a for loop. Signed-off-by: Colin Ian King Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/isci/port_config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/scsi/isci/port_config.c +++ b/drivers/scsi/isci/port_config.c @@ -291,7 +291,7 @@ sci_mpc_agent_validate_phy_configuration * Note: We have not moved the current phy_index so we will actually * compare the startting phy with itself. * This is expected and required to add the phy to the port. */ - while (phy_index < SCI_MAX_PHYS) { + for (; phy_index < SCI_MAX_PHYS; phy_index++) { if ((phy_mask & (1 << phy_index)) == 0) continue; sci_phy_get_sas_address(&ihost->phys[phy_index], @@ -311,7 +311,6 @@ sci_mpc_agent_validate_phy_configuration &ihost->phys[phy_index]); assigned_phy_mask |= (1 << phy_index); - phy_index++; } }