[PATCH] block: fix bsg_unregister and bsg_open race
From: Anatoliy Glagolev
Date: Wed Jun 13 2018 - 18:14:29 EST
The existing implementation allows races between bsg_unregister and
bsg_open paths. bsg_ungegister and request_queue cleanup and
deletion may start and complete right after bsg_get_device (in bsg_open path)
retrieves bsg_class_device and releases the mutex. Then bsg_open path
touches freed memory of bsg_class_device and request_queue.
One possible fix is to hold the mutex all the way through bsg_get_device
instead of releasing it after bsg_class_device retrieval.