From 13b3da7bd82ebd1b8feb9cd338fb712f40ef4fe3 Mon Sep 17 00:00:00 2001 From: vlnb Date: Mon, 12 May 2008 15:58:34 +0000 Subject: [PATCH] - Fixed GFP_KERNEL misuse. Reported independently by mbe1@charter.net and Erez Zilber - Fixed not sufficient in_irq() to determine atomic allocation context. Reported by mbe1@charter.net git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@365 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 4 ++-- scst/src/scst_priv.h | 5 +++++ scst/src/scst_targ.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 53681e1..bcbf42e 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1089,7 +1089,7 @@ static void scst_send_release(struct scst_device *dev) TRACE(TRACE_DEBUG | TRACE_SCSI, "%s", "Sending RELEASE req to " "SCSI mid-level"); rc = scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0, - sense, SCST_DEFAULT_TIMEOUT, 0, GFP_KERNEL); + sense, SCST_DEFAULT_TIMEOUT, 0, 0); TRACE_DBG("MODE_SENSE done: %x", rc); if (scsi_status_is_good(rc)) { @@ -2336,7 +2336,7 @@ int scst_obtain_device_parameters(struct scst_device *dev) TRACE(TRACE_SCSI, "%s", "Doing internal MODE_SENSE"); res = scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ, buffer, sizeof(buffer), sense_buffer, SCST_DEFAULT_TIMEOUT, - 0, GFP_KERNEL); + 0, 0); TRACE_DBG("MODE_SENSE done: %x", res); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 4fd0c87..48ba711 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -133,6 +133,11 @@ static inline int scst_get_context(void) return SCST_CONTEXT_DIRECT; } +static inline bool scst_is_context_gfp_atomic(void) +{ + return irqs_disabled() || in_atomic() || in_interrupt(); +} + extern unsigned long scst_max_cmd_mem; extern mempool_t *scst_mgmt_mempool; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 1e20592..6225391 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1086,7 +1086,8 @@ static void scst_do_cmd_done(struct scst_cmd *cmd, int result, } if (cmd->status == SAM_STAT_CHECK_CONDITION) - scst_alloc_set_sense(cmd, in_irq(), rq_sense, rq_sense_len); + scst_alloc_set_sense(cmd, scst_is_context_gfp_atomic(), + rq_sense, rq_sense_len); TRACE(TRACE_SCSI, "result=%x, cmd->status=%x, resid=%d, " "cmd->msg_status=%x, cmd->host_status=%x, " -- 2.17.1