Skip to content

Commit 8c7e7b8

Browse files
Dan Carpentermartinkpetersen
authored andcommitted
scsi: libsas: Use _safe() loop in sas_resume_port()
If sas_notify_lldd_dev_found() fails then this code calls: sas_unregister_dev(port, dev); which removes "dev", our list iterator, from the list. This could lead to an endless loop. We need to use list_for_each_entry_safe(). Link: https://lore.kernel.org/r/YKUeq6gwfGcvvhty@mwanda Fixes: 303694e ("[SCSI] libsas: suspend / resume support") Reviewed-by: John Garry <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b4150b6 commit 8c7e7b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/scsi/libsas/sas_port.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static bool phy_is_wideport_member(struct asd_sas_port *port, struct asd_sas_phy
2525

2626
static void sas_resume_port(struct asd_sas_phy *phy)
2727
{
28-
struct domain_device *dev;
28+
struct domain_device *dev, *n;
2929
struct asd_sas_port *port = phy->port;
3030
struct sas_ha_struct *sas_ha = phy->ha;
3131
struct sas_internal *si = to_sas_internal(sas_ha->core.shost->transportt);
@@ -44,7 +44,7 @@ static void sas_resume_port(struct asd_sas_phy *phy)
4444
* 1/ presume every device came back
4545
* 2/ force the next revalidation to check all expander phys
4646
*/
47-
list_for_each_entry(dev, &port->dev_list, dev_list_node) {
47+
list_for_each_entry_safe(dev, n, &port->dev_list, dev_list_node) {
4848
int i, rc;
4949

5050
rc = sas_notify_lldd_dev_found(dev);

0 commit comments

Comments
 (0)