mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 15:04:27 +08:00
scsi: qedf: Do not put host in qedf_vport_create() unconditionally
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 <jhasan@marvell.com> Signed-off-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
696770e72f
commit
79c932cd6a
@ -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));
|
fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf));
|
||||||
QEDF_WARN(&(base_qedf->dbg_ctx), "Failed to create vport, "
|
QEDF_WARN(&(base_qedf->dbg_ctx), "Failed to create vport, "
|
||||||
"WWPN (0x%s) already exists.\n", buf);
|
"WWPN (0x%s) already exists.\n", buf);
|
||||||
goto err1;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atomic_read(&base_qedf->link_state) != QEDF_LINK_UP) {
|
if (atomic_read(&base_qedf->link_state) != QEDF_LINK_UP) {
|
||||||
QEDF_WARN(&(base_qedf->dbg_ctx), "Cannot create vport "
|
QEDF_WARN(&(base_qedf->dbg_ctx), "Cannot create vport "
|
||||||
"because link is not up.\n");
|
"because link is not up.\n");
|
||||||
rc = -EIO;
|
return -EIO;
|
||||||
goto err1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vn_port = libfc_vport_create(vport, sizeof(struct qedf_ctx));
|
vn_port = libfc_vport_create(vport, sizeof(struct qedf_ctx));
|
||||||
if (!vn_port) {
|
if (!vn_port) {
|
||||||
QEDF_WARN(&(base_qedf->dbg_ctx), "Could not create lport "
|
QEDF_WARN(&(base_qedf->dbg_ctx), "Could not create lport "
|
||||||
"for vport.\n");
|
"for vport.\n");
|
||||||
rc = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf));
|
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) {
|
if (rc) {
|
||||||
QEDF_ERR(&(base_qedf->dbg_ctx), "Could not allocate memory "
|
QEDF_ERR(&(base_qedf->dbg_ctx), "Could not allocate memory "
|
||||||
"for lport stats.\n");
|
"for lport stats.\n");
|
||||||
goto err2;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
fc_set_wwnn(vn_port, vport->node_name);
|
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) {
|
if (rc) {
|
||||||
QEDF_WARN(&base_qedf->dbg_ctx,
|
QEDF_WARN(&base_qedf->dbg_ctx,
|
||||||
"Error adding Scsi_Host rc=0x%x.\n", rc);
|
"Error adding Scsi_Host rc=0x%x.\n", rc);
|
||||||
goto err2;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set default dev_loss_tmo based on module parameter */
|
/* 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.host_no = vn_port->host->host_no;
|
||||||
vport_qedf->dbg_ctx.pdev = base_qedf->pdev;
|
vport_qedf->dbg_ctx.pdev = base_qedf->pdev;
|
||||||
|
|
||||||
err2:
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
scsi_host_put(vn_port->host);
|
scsi_host_put(vn_port->host);
|
||||||
err1:
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1968,8 +1967,7 @@ static int qedf_vport_destroy(struct fc_vport *vport)
|
|||||||
fc_lport_free_stats(vn_port);
|
fc_lport_free_stats(vn_port);
|
||||||
|
|
||||||
/* Release Scsi_Host */
|
/* Release Scsi_Host */
|
||||||
if (vn_port->host)
|
scsi_host_put(vn_port->host);
|
||||||
scsi_host_put(vn_port->host);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user