Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3702857pxb; Mon, 24 Jan 2022 15:49:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkvRwm9airm/Knuw/PNQnjK69fKgWbJp87j4y4D4vHPa41Uzk8Bt2dUPfwjK4wVuOOBdkw X-Received: by 2002:a17:902:6b89:b0:149:7aa8:d98c with SMTP id p9-20020a1709026b8900b001497aa8d98cmr16576128plk.72.1643068154986; Mon, 24 Jan 2022 15:49:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068154; cv=none; d=google.com; s=arc-20160816; b=xSTcJp559yZ8qwUnZ0y38ow1aweWfXWASx01yfHtnc9Ht3Of5OXj0qIVgE5cwFnkrB apbcFNAugZm/bT2puC5eKNnOIBSTpxMGY9ECBOUL8Qy7/kvSHDB03Uskd/51n2jbVr58 pY8ljZkL7idgblY7VSinmZewVYGUShoXl6punAnHQLCiHYY/HhPhW5HZtUZ7xXoP7jOu fMC6P/zNBfLqJpKJYvds71cW04wqTJESYrSwcE8ZeU5dDC35rh6ETcEDpRL2fHvOUEHF cFpDUjUSkWIzkfa5hwsphnb28Kivgdq7t9q9NkFHVmdV4U591h+Yw2FmoJuKQQTn/O2i NSDg== 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=gE60OQXu09RdNnVcZzFTcfWLQDcUwqN3D5l4ecFI1J0=; b=SzbWaEaJBQQGuUgcOggZSaNFgyvMDaRZbXbEm3/9G3+i2qfAPKcANv3JW4RYRxZbuJ rw7kol0JH2UAvnuPu+Po2uLn889WYAsOOung6D0oJo2vvy9YCr0cW/Geoucu4Hq/Y/2K rVaD60wuIXw9+l74LFWw04H0cciY2b7qpmgafLRBbwHj1ZdWnuiAzoufqzOHScc3u3vi z/wGX63mn+W9LeK9j7c8arBX+qRA6DYTZ0cZ4QI2XoU/utrvmc/M4LdwS9bSTrz79g6s 0ESMAuLGmwbtvCPbd2uLr4iShKpN7pYZt03GVK/53tqMbqLxDDplq+ZQ73SC2WwkC8Qg muZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vCqRP5jk; 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 c10si14731290plg.392.2022.01.24.15.49.03; Mon, 24 Jan 2022 15:49:14 -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=vCqRP5jk; 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 S2362992AbiAXXnT (ORCPT + 99 others); Mon, 24 Jan 2022 18:43:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1843473AbiAXXED (ORCPT ); Mon, 24 Jan 2022 18:04:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6AEC06C5B3; Mon, 24 Jan 2022 13:15:37 -0800 (PST) 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 B0F6261484; Mon, 24 Jan 2022 21:15:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B6B2C340E4; Mon, 24 Jan 2022 21:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058936; bh=XiEZal2TU1ajBjFbZzAocbQPIe4D4ZjRyO1MiTh+6rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vCqRP5jkIoFVAM1p5P2Q5fcjHFQIindRnGr1pDIZ9lp3o9BGAekVa67iFadg7xva8 r/qnHzHl6Nz+N9ykD+ji/QnFlfGa1iOHSzqa05RyxM/ttzk5JKK8Pyi3hn8RWn+rfp mbyiEAVkYnuBjw0HnX0LVDZvI7whc8fHqvuFTAGs= 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.16 0451/1039] scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd() Date: Mon, 24 Jan 2022 19:37:20 +0100 Message-Id: <20220124184140.452294711@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 124cb69740c67..4390c8b9170cd 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