Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3603029pxb; Mon, 24 Jan 2022 13:17:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJw14Y7Gq4T/WpyelS/tOoGnQHBtRyPiV5b81INNMvS7GTjruLoWrnRY9f+8ule3L8I41duM X-Received: by 2002:aa7:88c9:0:b0:4c9:319e:ecb7 with SMTP id k9-20020aa788c9000000b004c9319eecb7mr5811292pff.58.1643059024105; Mon, 24 Jan 2022 13:17:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059024; cv=none; d=google.com; s=arc-20160816; b=tM5iY8+pRHlcSqTBDRpA3RvQSKk1fgp8ttwDBqiExm+GMZqmA6ru9m9ITEAxIy9xzF 9gbtGisAQ1hGNAaz80Ktp0RpmCXvOMo+JofrZPKwHXQ7g7dYMGknGBWeYgD8s20nejxY MsL7jmXcj9A/+mCcPN+3M1b4STH8HSH3x93y0Xtjda5j3cSa1KDyP2pw9Ob8EDFN5Obw Lv6SrnuJGX0WFoDVZmGtk10XpNHX5loSDUunZdSWf2f6NYJkvACQvx9dM3b2C2N0ZDb1 Oa2EMUZc68ZtAk8ACMYD8NNozbyC1K6fEYpurp5wbyJL+BgB2wFWmwufTSRf9ppww96g Q/Xw== 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=E0NBOViYFx78i4BwenSMpUcZ5siixncIJm98NEXol1E=; b=Mh5qYL7K+1+EsRwXKcieKmSzb0YmJLxLWDTULCQmPJE1jmykqQ6HknPdLWPXm2N9D4 EjjBuoZDZuCc5iI9EI3WVPLBd0uzkONJKHTh18r5SueBcvtsVTEPe6MMCfIsrNRaeLPx ghBzUvLdlVnNVn3xi2ySUsysKmppMNH80HJitG/0DXv1iz2h0rpJNujE8oKzqv7I0tWZ yw2FnQLZ3RKQpH9Xvrot8jDGJWvvFXuSYWbSMbUqp3hpxl7XFqqCwoncgonwNF4/k6d/ ej9wYBFlX4zyYQTAzNFF4Bb7R3p7VNZxwZjSaXxRohS4IW5fh9LVt+BPNvtBXFKroo4e yb7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oCqS90HN; 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 b38si14510106pgm.393.2022.01.24.13.16.52; Mon, 24 Jan 2022 13:17:04 -0800 (PST) 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=oCqS90HN; 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 S1441871AbiAXUvr (ORCPT + 99 others); Mon, 24 Jan 2022 15:51:47 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:53486 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384043AbiAXU2r (ORCPT ); Mon, 24 Jan 2022 15:28:47 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 792B26150D; Mon, 24 Jan 2022 20:28:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A118C340E5; Mon, 24 Jan 2022 20:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056125; bh=ZzxFbQW2xAG/P4ZtqS8idql9d5dCZsMQurf939RG6pY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oCqS90HNx8XKJyaQgBgxi4PBWQ5bl44k1hVVe0HWI2M3ehmtwcCi1qNpoUcftBoTC TtdvLjwRWwTZ/bg+Gu6xNHPnJHFpn5dqRUNuMBOW2GKZfmU3x317WWKUXhgSgq48Pg x/lxNPa+pHyaDtzUEEHTu2ddXZpjQzciridEiOjo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vishakha Channapattan , Jack Wang , Igor Pylypiv , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 380/846] scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd() Date: Mon, 24 Jan 2022 19:38:17 +0100 Message-Id: <20220124184114.046825070@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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: Igor Pylypiv [ Upstream commit 606c54ae975ad3af540b505b46b55a687501711f ] Starting from commit 05c6c029a44d ("scsi: pm80xx: Increase number of supported queues") driver initializes only max_q_num queues. Do not use an invalid queue if the WARN_ON condition is true. Link: https://lore.kernel.org/r/20211101232825.2350233-4-ipylypiv@google.com Fixes: 7640e1eb8c5d ("scsi: pm80xx: Make mpi_build_cmd locking consistent") Reviewed-by: Vishakha Channapattan Acked-by: Jack Wang Signed-off-by: Igor Pylypiv Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/pm8001/pm8001_hwi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 639b7e38a1947..880e1f356defc 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1325,7 +1325,9 @@ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha, int q_index = circularQ - pm8001_ha->inbnd_q_tbl; int rv; - WARN_ON(q_index >= PM8001_MAX_INB_NUM); + if (WARN_ON(q_index >= pm8001_ha->max_q_num)) + return -EINVAL; + spin_lock_irqsave(&circularQ->iq_lock, flags); rv = pm8001_mpi_msg_free_get(circularQ, pm8001_ha->iomb_size, &pMessage); -- 2.34.1