diff mbox series

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

Message ID 20200923075130.12943-1-hare@suse.de
State New
Headers show
Series scsi_dh_alua: do not call 'BUG_ON' for non-existing sdev | expand

Commit Message

Hannes Reinecke Sept. 23, 2020, 7:51 a.m. UTC
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.

Reported-by: Brian Bunker <brian@purestorage.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index f32da0ca529e..e97b1d1ea123 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -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)