Re: [PATCH v2] scsi: libsas: Add rollback handling in the sas_register_phys() and sas_register_ha() when an error occurs.
From: John Garry
Date: Mon Dec 08 2025 - 04:11:14 EST
On 06/12/2025 06:06, wdhh6 wrote:
From: Chaohai Chen <wdhh6@xxxxxxxxxx>
In sas_register_phys(), if an error is triggered in the loop process,
we need to rollback the resources that have already been requested.
Add the sas_unregister_phys() when an error occurs in
sas_register_ha().
Signed-off-by: Chaohai Chen <wdhh6@xxxxxxxxxx>
Reviewed-by: John Garry <john.g.garry@xxxxxxxxxx>
+}
+
+void sas_unregister_phys(struct sas_ha_struct *sas_ha)
+{
+ int i;
+ struct asd_sas_phy *phy;
+
+ for (i = 0; i < sas_ha->num_phys; i++) {
+ phy = sas_ha->sas_phy[i];
nit: I think that it would be nicer to declare @phy within the loop,
like how it is done at the roolback label in sas_register_phys().
+ sas_phy_delete(phy->phy);
+ sas_phy_free(phy->phy);
+ }
}
const work_func_t sas_phy_event_fns[PHY_NUM_EVENTS] = {