- Fixed GFP_KERNEL misuse. Reported independently by mbe1@charter.net and Erez Zilbe...
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Mon, 12 May 2008 15:58:34 +0000 (15:58 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Mon, 12 May 2008 15:58:34 +0000 (15:58 +0000)
 - 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
scst/src/scst_priv.h
scst/src/scst_targ.c

index 53681e1..bcbf42e 100644 (file)
@@ -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);
 
index 4fd0c87..48ba711 100644 (file)
@@ -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;
index 1e20592..6225391 100644 (file)
@@ -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, "