diff mbox series

fix for kernel BUG at drivers/scsi/device_handler/scsi_dh_alua.c:662!

Message ID FF501332-F768-46E2-9CB4-CAD103952509@purestorage.com
State New
Headers show
Series fix for kernel BUG at drivers/scsi/device_handler/scsi_dh_alua.c:662! | expand

Commit Message

Brian Bunker Sept. 9, 2020, 5:08 p.m. UTC
Hello all,

It looks like I sent this email to the wrong mailing list according to RedHat so I am sending it here:

>From my earlier post:

https://www.redhat.com/archives/dm-devel/2020-September/msg00083.html


Would it be better to move the unsetting the address of sdev to NULL lower? This would protect
against the crash we see when the alua_rtpg function tries to access the sdev address
that has been set to NULL in alua_bus_detach by another thread.


Thanks,
Brian

Brian Bunker
SW Eng
brian@purestorage.com
diff mbox series

Patch

--- a/linux-5.4.17/drivers/scsi/device_handler/scsi_dh_alua.c	2020-07-29 22:48:30.000000000 -0600
+++ b/linux-5.4.17/drivers/scsi/device_handler/scsi_dh_alua.c	2020-09-07 13:38:23.771575702 -0600
@@ -1146,15 +1146,15 @@ 
 
 	spin_lock(&h->pg_lock);
 	pg = rcu_dereference_protected(h->pg, lockdep_is_held(&h->pg_lock));
-	rcu_assign_pointer(h->pg, NULL);
-	h->sdev = NULL;
-	spin_unlock(&h->pg_lock);
 	if (pg) {
 		spin_lock_irq(&pg->lock);
 		list_del_rcu(&h->node);
 		spin_unlock_irq(&pg->lock);
 		kref_put(&pg->kref, release_port_group);
 	}
+	rcu_assign_pointer(h->pg, NULL);
+	h->sdev = NULL;
+	spin_unlock(&h->pg_lock);
 	sdev->handler_data = NULL;
 	kfree(h);
 }