[SCSI] SCSI core kmalloc2kzalloc
[safe/jmp/linux-2.6] / drivers / scsi / scsi_ioctl.c
index 26f5bc6..36e9300 100644 (file)
@@ -241,10 +241,9 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
                buf_needed = (buf_needed + 511) & ~511;
                if (buf_needed > MAX_BUF)
                        buf_needed = MAX_BUF;
-               buf = kmalloc(buf_needed, gfp_mask);
+               buf = kzalloc(buf_needed, gfp_mask);
                if (!buf)
                        return -ENOMEM;
-               memset(buf, 0, buf_needed);
                if (inlen == 0) {
                        data_direction = DMA_FROM_DEVICE;
                } else if (outlen == 0 ) {
@@ -278,7 +277,7 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
         * Obtain the data to be sent to the device (if any).
         */
 
-       if(copy_from_user(buf, cmd_in + cmdlen, inlen))
+       if(inlen && copy_from_user(buf, cmd_in + cmdlen, inlen))
                goto error;
 
        switch (opcode) {
@@ -322,7 +321,7 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
                if (copy_to_user(cmd_in, sense, sb_len))
                        result = -EFAULT;
        } else {
-               if (copy_to_user(cmd_in, buf, outlen))
+               if (outlen && copy_to_user(cmd_in, buf, outlen))
                        result = -EFAULT;
        }