Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4617447pxj; Wed, 12 May 2021 09:19:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtSt5UuNDMLorDU/0EK8SltKPhe4a28Qo8tle84Xz+lESg4KeEcS/KSEvcUWxXtPDJxaXs X-Received: by 2002:a50:cc8f:: with SMTP id q15mr43471004edi.322.1620836399455; Wed, 12 May 2021 09:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836399; cv=none; d=google.com; s=arc-20160816; b=uVltGElvpGwz85FF6PCU/w+PHyjW//U4F23Kh3pVIbWHZF334S1/Wi3Yr3asy8JkIS VYogH+P8cq/xxyvTfbXPvuLm3Q6VHjxGGEt5fY1bzst9FXO8+rZy9JWHK0r6t1AoRNN6 NB1gSplQRNHG7GfBWRFFUmMEiWxbxwa/flng8HuAX1oiG71XBmnRtr8obyQivw9kQa/w ucikv847b962qrXzK5uZGBb4qQhqpFAtedxWJBne14zEs+2iPe+U8Zpoz+nyZhxt0Abo gjG9S0MXFujNziww/cWu0cJa4EgNy4Cm0DIdfD3fu4qrDPwnNi9bMUMo0pgvqyeGjf0c ibaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=71OiuIePjYJQGNqpIiYrh/mYZ0WgeQTuF/glzoJ2AhE=; b=ebPHLRWST7HXD9ljPqdiANEgEbMjOuNxNIhiXxsxVWu3k8/HXzEST9cONmyIOhe5l7 KFpryrAMMbcnzBOnKJJDI2yGsh7YWMTqlc+mhP4H6O8uNH+cVXLdOBq9YmZbZHRCYpRO E8t2H0AY3+7DUP092YQBheXRp8p/bTfUwS+nxcHtOxjR0CZrs5vJib5DlQ61K9DFtOKx PFTLV2/uRB1edSoZr6xYu8rxpCi+JBoyBAIEbydB99QGo1vv/r/LpClUz9J3Ed2JMczt x12AnT0jBiD/SOzqM3aOrnnccHidqp5UcJPPsKYoSFtOapMzU2Xgrm6RKiShlxh4Yh/G YbEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cSvDqnIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q1si328394ejy.298.2021.05.12.09.19.35; Wed, 12 May 2021 09:19:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cSvDqnIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236638AbhELQOf (ORCPT + 99 others); Wed, 12 May 2021 12:14:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:49218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233585AbhELPbR (ORCPT ); Wed, 12 May 2021 11:31:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 355C361952; Wed, 12 May 2021 15:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832576; bh=WNld1eSy458VrEp/IXDPSzEvOTPN2KtOsBr8ocAW6U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cSvDqnImGiLtaX2NANTigwIN72M58RVwpdIOvncJvQdq8uI18NDOddzy6iwg2ZuWk /nnYYectjgybZPpfAxdlLVLZr6klAy/eB4U4Y5w/76dm+aGFOuErOd+dJ9lbLbacrA tskBkKiJKZYLtBLm5EReRj2Crao/++anSiCFwqeQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Colin Ian King , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 329/530] scsi: pm80xx: Fix potential infinite loop Date: Wed, 12 May 2021 16:47:19 +0200 Message-Id: <20210512144830.620841332@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 40fa7394a1ad5706e795823276f2e394cca145d0 ] The for-loop iterates with a u8 loop counter i and compares this with the loop upper limit of pm8001_ha->max_q_num which is a u32 type. There is a potential infinite loop if pm8001_ha->max_q_num is larger than the u8 loop counter. Fix this by making the loop counter the same type as pm8001_ha->max_q_num. [mkp: this is purely theoretical, max_q_num is currently limited to 64] Link: https://lore.kernel.org/r/20210407135840.494747-1-colin.king@canonical.com Fixes: 65df7d1986a1 ("scsi: pm80xx: Fix chip initialization failure") Addresses-Coverity: ("Infinite loop") Reviewed-by: Johannes Thumshirn Signed-off-by: Colin Ian King Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index c4705269e39f..355d1c5f2194 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -643,7 +643,7 @@ static void init_pci_device_addresses(struct pm8001_hba_info *pm8001_ha) */ static int pm8001_chip_init(struct pm8001_hba_info *pm8001_ha) { - u8 i = 0; + u32 i = 0; u16 deviceid; pci_read_config_word(pm8001_ha->pdev, PCI_DEVICE_ID, &deviceid); /* 8081 controllers need BAR shift to access MPI space -- 2.30.2