]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Fix bug 7994 sleeping function called from invalid context
authorDouglas Gilbert <dougg@torque.net>
Wed, 7 Mar 2007 19:33:38 +0000 (14:33 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 13 Mar 2007 18:26:46 +0000 (11:26 -0700)
  - addresses the reported bug (with GFP_KERNEL -> GFP_ATOMIC)
  - improves error checking, and
  - is a subset of the changes to scsi_debug in lk 2.6.21-rc*

Compiled and lightly tested (in lk 2.6.21-rc2 environment).

Signed-off-by: Douglas Gilbert <dougg@torque.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/scsi/scsi_debug.c

index 30ee3d72c02151f0b56ca9b69b9c7d10aff7bbff..614c2c9af5b34a4701890552ee302a7c86dab916 100644 (file)
@@ -954,7 +954,9 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
        int alloc_len, n, ret;
 
        alloc_len = (cmd[3] << 8) + cmd[4];
-       arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_KERNEL);
+       arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_ATOMIC);
+       if (! arr)
+               return DID_REQUEUE << 16;
        if (devip->wlun)
                pq_pdt = 0x1e;  /* present, wlun */
        else if (scsi_debug_no_lun_0 && (0 == devip->lun))
@@ -1217,7 +1219,9 @@ static int resp_report_tgtpgs(struct scsi_cmnd * scp,
        alen = ((cmd[6] << 24) + (cmd[7] << 16) + (cmd[8] << 8)
                + cmd[9]);
 
-       arr = kzalloc(SDEBUG_MAX_TGTPGS_ARR_SZ, GFP_KERNEL);
+       arr = kzalloc(SDEBUG_MAX_TGTPGS_ARR_SZ, GFP_ATOMIC);
+       if (! arr)
+               return DID_REQUEUE << 16;
        /*
         * EVPD page 0x88 states we have two ports, one
         * real and a fake port with no device connected.
@@ -1996,6 +2000,8 @@ static int scsi_debug_slave_configure(struct scsi_device * sdp)
        if (sdp->host->max_cmd_len != SCSI_DEBUG_MAX_CMD_LEN)
                sdp->host->max_cmd_len = SCSI_DEBUG_MAX_CMD_LEN;
        devip = devInfoReg(sdp);
+       if (NULL == devip)
+               return 1;       /* no resources, will be marked offline */
        sdp->hostdata = devip;
        if (sdp->host->cmd_per_lun)
                scsi_adjust_queue_depth(sdp, SDEBUG_TAGGED_QUEUING,
@@ -2044,7 +2050,7 @@ static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev)
                }
        }
        if (NULL == open_devip) { /* try and make a new one */
-               open_devip = kzalloc(sizeof(*open_devip),GFP_KERNEL);
+               open_devip = kzalloc(sizeof(*open_devip),GFP_ATOMIC);
                if (NULL == open_devip) {
                        printk(KERN_ERR "%s: out of memory at line %d\n",
                                __FUNCTION__, __LINE__);