scsi: scsi_dh_alua: Avoid crash during alua_bus_detach()
authorHannes Reinecke <hare@suse.de>
Thu, 24 Sep 2020 10:45:59 +0000 (12:45 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 2 Nov 2020 23:09:49 +0000 (18:09 -0500)
commit5faf50e9e9fdc2117c61ff7e20da49cd6a29e0ca
treeabbe157a8252e3270e0569fe61c3bab1a7735998
parentaf61bc1e33d2c0ec22612b46050f5b58ac56a962
scsi: scsi_dh_alua: Avoid crash during alua_bus_detach()

alua_bus_detach() might be running concurrently with alua_rtpg_work(), so
we might trip over h->sdev == NULL and call BUG_ON().  The correct way of
handling it is to not set h->sdev to NULL in alua_bus_detach(), and call
rcu_synchronize() before the final delete to ensure that all concurrent
threads have left the critical section.  Then we can get rid of the
BUG_ON() and replace it with a simple if condition.

Link: https://lore.kernel.org/r/1600167537-12509-1-git-send-email-jitendra.khasdev@oracle.com
Link: https://lore.kernel.org/r/20200924104559.26753-1-hare@suse.de
Cc: Brian Bunker <brian@purestorage.com>
Acked-by: Brian Bunker <brian@purestorage.com>
Tested-by: Jitendra Khasdev <jitendra.khasdev@oracle.com>
Reviewed-by: Jitendra Khasdev <jitendra.khasdev@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/device_handler/scsi_dh_alua.c