Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3832385pxv; Mon, 19 Jul 2021 09:48:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+g8c7fZg7W2qW7fZ2Ev3sPEpZpTmHABos4s+5rPcOp1p7kVOS3FaAJOft10ZKaGNAQb98 X-Received: by 2002:aa7:df12:: with SMTP id c18mr35554357edy.62.1626713284434; Mon, 19 Jul 2021 09:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626713284; cv=none; d=google.com; s=arc-20160816; b=ycawFCX5O6pSE7Mirx51WFqdezcMvYj7woWWxz8XCkOa4cC2CCecoKCq1RVJVYB0+F oUFad+5AFdmweknQBSh0YmdjCu2KsUNLczEIIuH5m3ZTrw7jfsHZiX4ch5jN5umAqXC3 p/P5iXCt7WUTqMLASKgHJnsUyjElZ4ySGYhNlu7qjB14TlYgOO9y5a7wEb827ctY79ia Eom9KCXOADcB1jmlZKC8RyyTg2mfjyOgxBkQQkGOZFZDCtjmpI/MAwFE2C9DkSuULyGT L8UqribtiezKyo0ybSub6BjLTobv8eaFhAngEV/ibDtqoF6Xy8vVx3etHEqd0zoyaBKg 9WQg== 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=5XkBaasErA8ezZrbqaS6HVczg3actzmFQwqDOmWYrzE=; b=jfnxpMFEIiqwceREEDyE0LcGp6+n8ABqM86OR1Hcc8PctH03mNVyZrV23WZPtIve5d d3g847lpZrbANKmm1KCxIA/Ps4dMBWTiG9IPL2ksk6VlM177tyI7zdmkUrXrgLU2sWSU srbnno8iRtPqfprSq1GnP8XypV1bmCRAQo/NJpnRXV4AEqkCFCcHIQHbkmpFEAUPgcjC JXRJaU3dgFJUz2BZ1oj/Qsl9oBNEI3IToMxFeOE9I9V/sn0Mdixa8y91i0B10oZQABV/ HgNNJRvG0+G3yn5yUW/J1p4uDHBk+QYz9LLM8fr79VoT506ucTmuv6An5DSP6xnu4Kf2 s7hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VmD2HEL8; 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 u15si23713950edt.211.2021.07.19.09.47.42; Mon, 19 Jul 2021 09:48:04 -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=VmD2HEL8; 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 S1346988AbhGSQGC (ORCPT + 99 others); Mon, 19 Jul 2021 12:06:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:40612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344615AbhGSPGc (ORCPT ); Mon, 19 Jul 2021 11:06:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C8D3C61165; Mon, 19 Jul 2021 15:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626709618; bh=rK1DoQNkT9kWGisf/OmCpHW+y3EYSkxB4VV0pHgx9Zs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VmD2HEL8zJm+iVhk3jbx+/9YFz+6NJ+9DGmz9+un1YCLw/QoIhVTrCYThEONK+E6q HkNtgsz1JT1LFfzEhRdPL7z6QZ95Lxmi587c/38KaGf54mfwqFYSbCsA7POJT/I33i rjzb/x2F4nzsjos4xC13h2ON0x1xhvppNtO4NVDg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Duncan , Mike Christie , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 032/149] scsi: iscsi: Fix shost->max_id use Date: Mon, 19 Jul 2021 16:52:20 +0200 Message-Id: <20210719144909.063317271@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144901.370365147@linuxfoundation.org> References: <20210719144901.370365147@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: Mike Christie [ Upstream commit bdd4aad7ff92ae39c2e93c415bb6761cb8b584da ] The iscsi offload drivers are setting the shost->max_id to the max number of sessions they support. The problem is that max_id is not the max number of targets but the highest identifier the targets can have. To use it to limit the number of targets we need to set it to max sessions - 1, or we can end up with a session we might not have preallocated resources for. Link: https://lore.kernel.org/r/20210525181821.7617-15-michael.christie@oracle.com Reviewed-by: Lee Duncan Signed-off-by: Mike Christie Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/be2iscsi/be_main.c | 4 ++-- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- drivers/scsi/cxgbi/libcxgbi.c | 4 ++-- drivers/scsi/qedi/qedi_main.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 0760d0bd8a10..6fcd413c2ac9 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -416,7 +416,7 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev) "beiscsi_hba_alloc - iscsi_host_alloc failed\n"); return NULL; } - shost->max_id = BE2_MAX_SESSIONS; + shost->max_id = BE2_MAX_SESSIONS - 1; shost->max_channel = 0; shost->max_cmd_len = BEISCSI_MAX_CMD_LEN; shost->max_lun = BEISCSI_NUM_MAX_LUN; @@ -5318,7 +5318,7 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba) /* Re-enable UER. If different TPE occurs then it is recoverable. */ beiscsi_set_uer_feature(phba); - phba->shost->max_id = phba->params.cxns_per_ctrl; + phba->shost->max_id = phba->params.cxns_per_ctrl - 1; phba->shost->can_queue = phba->params.ios_per_ctrl; ret = beiscsi_init_port(phba); if (ret < 0) { diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 0b28d44d3573..949d20b72ec4 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -793,7 +793,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic) return NULL; shost->dma_boundary = cnic->pcidev->dma_mask; shost->transportt = bnx2i_scsi_xport_template; - shost->max_id = ISCSI_MAX_CONNS_PER_HBA; + shost->max_id = ISCSI_MAX_CONNS_PER_HBA - 1; shost->max_channel = 0; shost->max_lun = 512; shost->max_cmd_len = 16; diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index 2cd2761bd249..40d93fadd206 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -337,7 +337,7 @@ void cxgbi_hbas_remove(struct cxgbi_device *cdev) EXPORT_SYMBOL_GPL(cxgbi_hbas_remove); int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun, - unsigned int max_id, struct scsi_host_template *sht, + unsigned int max_conns, struct scsi_host_template *sht, struct scsi_transport_template *stt) { struct cxgbi_hba *chba; @@ -357,7 +357,7 @@ int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun, shost->transportt = stt; shost->max_lun = max_lun; - shost->max_id = max_id; + shost->max_id = max_conns - 1; shost->max_channel = 0; shost->max_cmd_len = 16; diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 4498add3d4d6..1ec42c5f0b2a 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -631,7 +631,7 @@ static struct qedi_ctx *qedi_host_alloc(struct pci_dev *pdev) goto exit_setup_shost; } - shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA; + shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA - 1; shost->max_channel = 0; shost->max_lun = ~0; shost->max_cmd_len = 16; -- 2.30.2