Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp891071pxj; Wed, 16 Jun 2021 16:26:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh1f1or07gmRC695xK5zjNH1XA1r8cFkR/TmE2MJ10d3huoAv1KgBBtMB5ar5TU3CUxxTh X-Received: by 2002:a05:6402:35d1:: with SMTP id z17mr2676737edc.159.1623886015922; Wed, 16 Jun 2021 16:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623886015; cv=none; d=google.com; s=arc-20160816; b=Ay4Hr8ui/txowd/Dsno4B1o1TSK3fGeipJ0gDzkH5L+oqHiD9TG2cZDAMuoVG2sIID 3eqHLxKksW6rhF5KmSBxCV7fnvS2XAfgxzidf2/IKbukFBtD+rVJBwJXCwHrPXjhcw32 z0//nVotozIS8JXM5h/RcZTtBzEg+8ELK1F24BbG9dsqqEW0+kalpq9BH2ytdqOVvH0/ 1huM5Yic/8DoZTS5e7qYeYPdqPo3oNUXPXMyHcABBNZo3JHpgftgj+Tvs/aVj9Iu2gut MwaM2lNcQ+XCn+nH9e/OS9DDsdU6vWRWstG7XXKAIiJLuU7RTqWVRB21xwyVACqiJbb3 eOdg== 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=7tX5YGCSPbyyKhXpCYEJ/euu1QWtAhBCfevzkX7FHGM=; b=eoBlGBTq8xvd02/YkOWOE1NQ+leZrLKMtSzucqlvCRT6j1zrjasxPOFmQqsbiUv7/g 91HnA4QaQ2jum5d3rZ7tBnGxMX2rX28dYPYCQHXSkyFsqORGW7/Fou1CKSJxQjq+Q5wx Xp1lAycmTAwesYKs7GgUV77jPZtmB4HxZrWZdRTk5gclb9bijtlMV4qXueOjm+x29z62 uK5115eUgbLx4gdGV0k8IxmEs3HyR2Ur/kHgUNo7Nv1m2nFXhEUhPeuvDg3ukA2EvVsV xOOjfk1xL7jN9QyYBQTCwyketpZD7R3+p/XqjbitnqfCdyDLsyNa7m+Bp2AeLOVoL/zL v7og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZLcn2DWm; 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 y18si3403730edd.585.2021.06.16.16.26.33; Wed, 16 Jun 2021 16:26:55 -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=ZLcn2DWm; 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 S235024AbhFPPqB (ORCPT + 99 others); Wed, 16 Jun 2021 11:46:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:50640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234733AbhFPPmH (ORCPT ); Wed, 16 Jun 2021 11:42:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56C0C61001; Wed, 16 Jun 2021 15:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623857885; bh=a4TIiWANEKxTnYf+JVI7YM6TQKyxchagbhSFNk43bco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLcn2DWmxgQVTG0db4j4OKfEh5AirQV1lk92lTa9lq0cpRFlzTPsZfKfZievW0llw bN85pWrxXAVmTqqsyzeFLYyjGiqwbd6/B7jswqeFsciKwtgioeefex5aT6/4JBzK0b 5e8zs1sIsHCsCHTIEh/p9ySvGOJeXqaJ6Iw981OE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Javed Hasan , Daniel Wagner , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.12 32/48] scsi: qedf: Do not put host in qedf_vport_create() unconditionally Date: Wed, 16 Jun 2021 17:33:42 +0200 Message-Id: <20210616152837.662912901@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210616152836.655643420@linuxfoundation.org> References: <20210616152836.655643420@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: Daniel Wagner [ Upstream commit 79c932cd6af9829432888c4a0001d01793a09f12 ] Do not drop reference count on vn_port->host in qedf_vport_create() unconditionally. Instead drop the reference count in qedf_vport_destroy(). Link: https://lore.kernel.org/r/20210521143440.84816-1-dwagner@suse.de Reported-by: Javed Hasan Signed-off-by: Daniel Wagner Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qedf/qedf_main.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index e5076f09d5ed..16a0470aedfc 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -1827,22 +1827,20 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf)); QEDF_WARN(&(base_qedf->dbg_ctx), "Failed to create vport, " "WWPN (0x%s) already exists.\n", buf); - goto err1; + return rc; } if (atomic_read(&base_qedf->link_state) != QEDF_LINK_UP) { QEDF_WARN(&(base_qedf->dbg_ctx), "Cannot create vport " "because link is not up.\n"); - rc = -EIO; - goto err1; + return -EIO; } vn_port = libfc_vport_create(vport, sizeof(struct qedf_ctx)); if (!vn_port) { QEDF_WARN(&(base_qedf->dbg_ctx), "Could not create lport " "for vport.\n"); - rc = -ENOMEM; - goto err1; + return -ENOMEM; } fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf)); @@ -1866,7 +1864,7 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) if (rc) { QEDF_ERR(&(base_qedf->dbg_ctx), "Could not allocate memory " "for lport stats.\n"); - goto err2; + goto err; } fc_set_wwnn(vn_port, vport->node_name); @@ -1884,7 +1882,7 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) if (rc) { QEDF_WARN(&base_qedf->dbg_ctx, "Error adding Scsi_Host rc=0x%x.\n", rc); - goto err2; + goto err; } /* Set default dev_loss_tmo based on module parameter */ @@ -1925,9 +1923,10 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) vport_qedf->dbg_ctx.host_no = vn_port->host->host_no; vport_qedf->dbg_ctx.pdev = base_qedf->pdev; -err2: + return 0; + +err: scsi_host_put(vn_port->host); -err1: return rc; } @@ -1968,8 +1967,7 @@ static int qedf_vport_destroy(struct fc_vport *vport) fc_lport_free_stats(vn_port); /* Release Scsi_Host */ - if (vn_port->host) - scsi_host_put(vn_port->host); + scsi_host_put(vn_port->host); out: return 0; -- 2.30.2