From efff5e2a2059ea2bdf7ec10ddcd7a9212ca97daa Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 13 Jan 2015 08:51:08 +0000 Subject: [PATCH] scst_parse_unmap_descriptors(): Avoid using GFP_KERNEL in atomic context Reported-by: Shahar Salzman Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5964 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_targ.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 54b49ee3c..cb6f56f3f 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1734,8 +1734,16 @@ static int scst_tgt_pre_exec(struct scst_cmd *cmd) out_descr: if (unlikely(cmd->op_flags & SCST_DESCRIPTORS_BASED)) { - int r = scst_parse_descriptors(cmd); - if (unlikely(r != 0)) + if (scst_cmd_atomic(cmd)) { + /* + * Switch to thread context such that + * scst_parse_descriptors() can use GFP_KERNEL instead + * of GFP_ATOMIC. + */ + res = SCST_CMD_STATE_RES_NEED_THREAD; + goto out; + } + if (unlikely(scst_parse_descriptors(cmd) != 0)) goto out; }