[PATCH] scsi: libsas: Fix potential double put when unregistering phys
From: Guangshuo Li
Date: Sat Dec 05 2026 - 08:52:10 EST
sas_phy_delete() already removes the registered PHY and drops its
device reference. Calling sas_phy_free() afterwards drops that
reference again and can access the released PHY.
Do not free PHYs again after deleting them.
This issue was found by our static analysis tool under development.
Fixes: 362432e9b9ae ("scsi: libsas: Add rollback handling when an error occurs")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/scsi/libsas/sas_phy.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/scsi/libsas/sas_phy.c b/drivers/scsi/libsas/sas_phy.c
index 58f08dc2c187..d8a42a0603e9 100644
--- a/drivers/scsi/libsas/sas_phy.c
+++ b/drivers/scsi/libsas/sas_phy.c
@@ -162,7 +162,6 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
struct asd_sas_phy *phy = sas_ha->sas_phy[i];
sas_phy_delete(phy->phy);
- sas_phy_free(phy->phy);
}
return err;
}
@@ -175,7 +174,6 @@ void sas_unregister_phys(struct sas_ha_struct *sas_ha)
struct asd_sas_phy *phy = sas_ha->sas_phy[i];
sas_phy_delete(phy->phy);
- sas_phy_free(phy->phy);
}
}
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907