[PATCH] block cleanups: Fix iosched module refcount leak
[powerpc.git] / drivers / block / scsi_ioctl.c
index b35cb75..382dea7 100644 (file)
@@ -123,6 +123,7 @@ static int verify_command(struct file *file, unsigned char *cmd)
                safe_for_read(READ_12),
                safe_for_read(READ_16),
                safe_for_read(READ_BUFFER),
+               safe_for_read(READ_DEFECT_DATA),
                safe_for_read(READ_LONG),
                safe_for_read(INQUIRY),
                safe_for_read(MODE_SENSE),
@@ -167,6 +168,7 @@ static int verify_command(struct file *file, unsigned char *cmd)
                safe_for_write(WRITE_VERIFY_12),
                safe_for_write(WRITE_16),
                safe_for_write(WRITE_LONG),
+               safe_for_write(WRITE_LONG_2),
                safe_for_write(ERASE),
                safe_for_write(GPCMD_MODE_SELECT_10),
                safe_for_write(MODE_SELECT),
@@ -199,15 +201,15 @@ static int verify_command(struct file *file, unsigned char *cmd)
                        return 0;
        }
 
+       /* And root can do any command.. */
+       if (capable(CAP_SYS_RAWIO))
+               return 0;
+
        if (!type) {
                cmd_type[cmd[0]] = CMD_WARNED;
                printk(KERN_WARNING "scsi: unknown opcode 0x%02x\n", cmd[0]);
        }
 
-       /* And root can do any command.. */
-       if (capable(CAP_SYS_RAWIO))
-               return 0;
-
        /* Otherwise fail it with an "Operation not permitted" */
        return -EPERM;
 }
@@ -216,7 +218,7 @@ static int sg_io(struct file *file, request_queue_t *q,
                struct gendisk *bd_disk, struct sg_io_hdr *hdr)
 {
        unsigned long start_time;
-       int reading, writing, ret = 0;
+       int writing = 0, ret = 0;
        struct request *rq;
        struct bio *bio;
        char sense[SCSI_SENSE_BUFFERSIZE];
@@ -234,19 +236,15 @@ static int sg_io(struct file *file, request_queue_t *q,
        if (hdr->dxfer_len > (q->max_sectors << 9))
                return -EIO;
 
-       reading = writing = 0;
        if (hdr->dxfer_len)
                switch (hdr->dxfer_direction) {
                default:
                        return -EINVAL;
                case SG_DXFER_TO_FROM_DEV:
-                       reading = 1;
-                       /* fall through */
                case SG_DXFER_TO_DEV:
                        writing = 1;
                        break;
                case SG_DXFER_FROM_DEV:
-                       reading = 1;
                        break;
                }
 
@@ -312,7 +310,7 @@ static int sg_io(struct file *file, request_queue_t *q,
         * (if he doesn't check that is his problem).
         * N.B. a non-zero SCSI status is _not_ necessarily an error.
         */
-       blk_execute_rq(q, bd_disk, rq);
+       blk_execute_rq(q, bd_disk, rq, 0);
 
        /* write to all output members */
        hdr->status = 0xff & rq->errors;
@@ -424,7 +422,7 @@ static int sg_scsi_ioctl(struct file *file, request_queue_t *q,
        rq->data_len = bytes;
        rq->flags |= REQ_BLOCK_PC;
 
-       blk_execute_rq(q, bd_disk, rq);
+       blk_execute_rq(q, bd_disk, rq, 0);
        err = rq->errors & 0xff;        /* only 8 bit SCSI status */
        if (err) {
                if (rq->sense_len && rq->sense) {
@@ -577,7 +575,7 @@ int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd,
                        rq->cmd[0] = GPCMD_START_STOP_UNIT;
                        rq->cmd[4] = 0x02 + (close != 0);
                        rq->cmd_len = 6;
-                       err = blk_execute_rq(q, bd_disk, rq);
+                       err = blk_execute_rq(q, bd_disk, rq, 0);
                        blk_put_request(rq);
                        break;
                default: