Skip to contentSkip to conversation

scsi: zfcp: move the position of put_device

PATCH In review Qinglang Miao 2 participants 2 messages Dec 1, 2020 – Dec 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: zfcp: move the position of put_device

Have the put_device() call after device_unregister() in both zfcp_unit_remove() and zfcp_sysfs_port_remove_store() to make it more natural, for put_device() ought to be the last time we touch the object in both functions.

And add comments after put_device to make codes clearer.

---
v2: add comments after put_device as Steffen suggested.

 drivers/s390/scsi/zfcp_sysfs.c | 4 ++--
 drivers/s390/scsi/zfcp_unit.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/s390/scsi/zfcp_sysfs.c +2 -2
index 8d9662e8b..ef6d35a37 100644
@@ -327,10 +327,10 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
 	list_del(&port->list);
 	write_unlock_irq(&adapter->port_list_lock);
 
-	put_device(&port->dev);
-
 	zfcp_erp_port_shutdown(port, 0, "syprs_1");
 	device_unregister(&port->dev);
+
+	put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */
  out:
 	zfcp_ccw_adapter_put(adapter);
 	return retval ? retval : (ssize_t) count;
drivers/s390/scsi/zfcp_unit.c +2 -2
index e67bf7388..59333f025 100644
@@ -255,9 +255,9 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
 		scsi_device_put(sdev);
 	}
 
-	put_device(&unit->dev);
-
 	device_unregister(&unit->dev);
 
+	put_device(&unit->dev); /* undo _zfcp_unit_find() */
+
 	return 0;
 }
Signature · 1 line
2.23.0
#1 lore raw
Quoted 10 lines · Qinglang Miao

Have the put_device() call after device_unregister() in both zfcp_unit_remove() and zfcp_sysfs_port_remove_store() to make it more natural, for put_device() ought to be the last time we touch the object in both functions.

And add comments after put_device to make codes clearer.

Quoted 7 lines

---
v2: add comments after put_device as Steffen suggested.

 drivers/s390/scsi/zfcp_sysfs.c | 4 ++--
 drivers/s390/scsi/zfcp_unit.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Got a bit delayed.
Looks good, I queue it, and we send it with the changes for 5.12 once the merge window for 5.11 is over.

Thanks.

Signature · 4 lines
Best Regards, Benjamin Block  / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH    /    https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen         /        Gesch�ftsf�hrung: Dirk Wittkopp
Sitz der Gesellschaft: B�blingen / Registergericht: AmtsG Stuttgart, HRB 243294