]> git.hungrycats.org Git - linux/commitdiff
[PATCH] scsi_ioctl reference counting
authorJens Axboe <axboe@suse.de>
Thu, 7 Aug 2003 02:58:43 +0000 (19:58 -0700)
committerJens Axboe <axboe@suse.de>
Thu, 7 Aug 2003 02:58:43 +0000 (19:58 -0700)
Now that we properly track queue references, that showed a bug in
scsi_ioctl.c, where it was dropping queues that it had never properly
gotten in the first place.

drivers/block/scsi_ioctl.c

index 68e0d250b623072cb9797186b53657d70f3edfce..ea340cc89bd4784590f17ce433300368d3262318 100644 (file)
@@ -406,26 +406,37 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
        if (!q)
                return -ENXIO;
 
+       if (blk_get_queue(q))
+               return -ENXIO;
+
        switch (cmd) {
                /*
                 * new sgv3 interface
                 */
                case SG_GET_VERSION_NUM:
-                       return sg_get_version((int *) arg);
+                       err = sg_get_version((int *) arg);
+                       break;
                case SCSI_IOCTL_GET_IDLUN:
-                       return scsi_get_idlun(q, (int *) arg);
+                       err = scsi_get_idlun(q, (int *) arg);
+                       break;
                case SCSI_IOCTL_GET_BUS_NUMBER:
-                       return scsi_get_bus(q, (int *) arg);
+                       err = scsi_get_bus(q, (int *) arg);
+                       break;
                case SG_SET_TIMEOUT:
-                       return sg_set_timeout(q, (int *) arg);
+                       err = sg_set_timeout(q, (int *) arg);
+                       break;
                case SG_GET_TIMEOUT:
-                       return sg_get_timeout(q);
+                       err = sg_get_timeout(q);
+                       break;
                case SG_GET_RESERVED_SIZE:
-                       return sg_get_reserved_size(q, (int *) arg);
+                       err = sg_get_reserved_size(q, (int *) arg);
+                       break;
                case SG_SET_RESERVED_SIZE:
-                       return sg_set_reserved_size(q, (int *) arg);
+                       err = sg_set_reserved_size(q, (int *) arg);
+                       break;
                case SG_EMULATED_HOST:
-                       return sg_emulated_host(q, (int *) arg);
+                       err = sg_emulated_host(q, (int *) arg);
+                       break;
                case SG_IO:
                        err = bd_claim(bdev, current);
                        if (err)
@@ -437,8 +448,9 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
                 * old junk scsi send command ioctl
                 */
                case SCSI_IOCTL_SEND_COMMAND:
+                       err = -EINVAL;
                        if (!arg)
-                               return -EINVAL;
+                               break;
 
                        err = bd_claim(bdev, current);
                        if (err)
@@ -449,11 +461,6 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
                case CDROMCLOSETRAY:
                        close = 1;
                case CDROMEJECT:
-                       if (blk_get_queue(q)) {
-                               err = -ENXIO;
-                               break;
-                       }
-                               
                        rq = blk_get_request(q, WRITE, __GFP_WAIT);
                        rq->flags |= REQ_BLOCK_PC;
                        rq->data = NULL;
@@ -467,7 +474,7 @@ int scsi_cmd_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long ar
                        blk_put_request(rq);
                        break;
                default:
-                       return -ENOTTY;
+                       err = -ENOTTY;
        }
 
        blk_put_queue(q);