Skip to contentSkip to conversation

scsi_dh_alua: do not call 'BUG_ON' for non-existing sdev

PATCH New Hannes Reinecke 1 participant 1 message Sep 23, 2020 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi_dh_alua: do not call 'BUG_ON' for non-existing sdev

When evaluating the target port group state we might race with device removal, causing the code to iterate over sdevs which have been removed.
This situation doesn't warrant a BUG_ON() statement as we can easily recover from here.
So replace the BUG_ON() with a simple 'if' condition.

---
 drivers/scsi/device_handler/scsi_dh_alua.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +4 -2
index f32da0ca529e..e97b1d1ea123 100644
@@ -659,7 +659,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 					list_for_each_entry_rcu(h,
 						&tmp_pg->dh_list, node) {
 						/* h->sdev should always be valid */
-						BUG_ON(!h->sdev);
+						if (!h->sdev)
+							continue;
 						h->sdev->access_state = desc[0];
 					}
 					rcu_read_unlock();
@@ -705,7 +706,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 			pg->expiry = 0;
 			rcu_read_lock();
 			list_for_each_entry_rcu(h, &pg->dh_list, node) {
-				BUG_ON(!h->sdev);
+				if (!h->sdev)
+					continue;
 				h->sdev->access_state =
 					(pg->state & SCSI_ACCESS_STATE_MASK);
 				if (pg->pref)
Signature · 1 line
2.26.2