Skip to content

Commit 7a165a8

Browse files
Xingui Yangmartinkpetersen
authored andcommitted
scsi: libsas: Set port when ex_phy is added or deleted
We found that when ex_phy was attached and added to the parent wide port, ex_phy->port was not set, resulting in sas_unregister_devs_sas_addr() not calling sas_port_delete_phy() when deleting the phy, and the deleted phy was still on the parent wide port's phy_list. When we use sas_port_add_ex_phy() to set ex_phy->port to solve the above problem, we find that after all the phys of the parent_port are removed and the number of phy becomes 0, the parent_port will not be set to NULL. This causes the freed parent port to be used when attaching a new ex_phy in sas_ex_add_parent_port(). Use sas_port_add_ex_phy() instead of sas_port_add_phy() to set ex_phy->port when ex_phy is added to the parent port, and set ex_dev->parent_port to NULL when the number of phy on the port becomes 0. Signed-off-by: Xingui Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 48032c0 commit 7a165a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/scsi/libsas/sas_expander.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void sas_ex_add_parent_port(struct domain_device *dev, int phy_id)
4545
BUG_ON(sas_port_add(ex->parent_port));
4646
sas_port_mark_backlink(ex->parent_port);
4747
}
48-
sas_port_add_phy(ex->parent_port, ex_phy->phy);
48+
sas_port_add_ex_phy(ex->parent_port, ex_phy);
4949
}
5050

5151
/* ---------- SMP task management ---------- */
@@ -1864,9 +1864,12 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,
18641864
if (phy->port) {
18651865
sas_port_delete_phy(phy->port, phy->phy);
18661866
sas_device_set_phy(found, phy->port);
1867-
if (phy->port->num_phys == 0)
1867+
if (phy->port->num_phys == 0) {
18681868
list_add_tail(&phy->port->del_list,
18691869
&parent->port->sas_port_del_list);
1870+
if (ex_dev->parent_port == phy->port)
1871+
ex_dev->parent_port = NULL;
1872+
}
18701873
phy->port = NULL;
18711874
}
18721875
}

0 commit comments

Comments
 (0)