Skip to content

Commit 90449f2

Browse files
bvanasschemartinkpetersen
authored andcommitted
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] Closes: https://lore.kernel.org/linux-scsi/[email protected]/ Cc: Hannes Reinecke <[email protected]> Cc: [email protected] Fixes: 97d27b0 ("scsi: sg: close race condition in sg_remove_sfp_usercontext()") Signed-off-by: Bart Van Assche <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e696518 commit 90449f2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/scsi/sg.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,9 +2208,17 @@ sg_remove_sfp_usercontext(struct work_struct *work)
22082208
write_lock_irqsave(&sfp->rq_list_lock, iflags);
22092209
while (!list_empty(&sfp->rq_list)) {
22102210
srp = list_first_entry(&sfp->rq_list, Sg_request, entry);
2211-
sg_finish_rem_req(srp);
22122211
list_del(&srp->entry);
2212+
write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
2213+
2214+
sg_finish_rem_req(srp);
2215+
/*
2216+
* sg_rq_end_io() uses srp->parentfp. Hence, only clear
2217+
* srp->parentfp after blk_mq_free_request() has been called.
2218+
*/
22132219
srp->parentfp = NULL;
2220+
2221+
write_lock_irqsave(&sfp->rq_list_lock, iflags);
22142222
}
22152223
write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
22162224

0 commit comments

Comments
 (0)