scsi: sg: Do not sleep in atomic context
Subsystems (3)
PATCH 1/1 scsi: sg: Do not sleep in atomic context
sg_finish_rem_req() calls blk_rq_unmap_user(). The latter function may sleep. Hence, call sg_finish_rem_req() with interrupts enabled instead of disabled.
Reported-by [email protected]
Cc Hannes Reinecke <[email protected]>
Fixes 97d27b0dd015 ("scsi: sg: close race condition in sg_remove_sfp_usercontext()")
Signed-off-by Bart Van Assche <[email protected]>
--- drivers/scsi/sg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/scsi/sg.c +9 -1
@@ -2208,9 +2208,17 @@ sg_remove_sfp_usercontext(struct work_struct *work)write_lock_irqsave (&sfp->rq_list_lock, iflags);while (!list_empty (&sfp->rq_list)) { srp =list_first_entry (&sfp->rq_list, Sg_request, entry); -sg_finish_rem_req (srp);list_del (&srp->entry); +write_unlock_irqrestore (&sfp->rq_list_lock, iflags); + +sg_finish_rem_req (srp); +/* +* sg_rq_end_io() uses srp->parentfp. Hence, only clear +* srp->parentfp after blk_mq_free_request() has been called. +*/ srp->parentfp =NULL ; + +write_lock_irqsave (&sfp->rq_list_lock, iflags); }write_unlock_irqrestore (&sfp->rq_list_lock, iflags);