]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/scsi/sd.c
Merge branch 'master' into for-linus
[net-next-2.6.git] / drivers / scsi / sd.c
index 255da53e5a01a1dd970fac95b2106888b6e91c6b..a82ab3e2b4f7af5d05019e57874ff7a33e46bd57 100644 (file)
@@ -1196,19 +1196,10 @@ static int sd_done(struct scsi_cmnd *SCpnt)
                SCpnt->result = 0;
                memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
                break;
-       case ABORTED_COMMAND:
-               if (sshdr.asc == 0x10) { /* DIF: Disk detected corruption */
-                       scsi_print_result(SCpnt);
-                       scsi_print_sense("sd", SCpnt);
+       case ABORTED_COMMAND: /* DIF: Target detected corruption */
+       case ILLEGAL_REQUEST: /* DIX: Host detected corruption */
+               if (sshdr.asc == 0x10)
                        good_bytes = sd_completed_bytes(SCpnt);
-               }
-               break;
-       case ILLEGAL_REQUEST:
-               if (sshdr.asc == 0x10) { /* DIX: HBA detected corruption */
-                       scsi_print_result(SCpnt);
-                       scsi_print_sense("sd", SCpnt);
-                       good_bytes = sd_completed_bytes(SCpnt);
-               }
                break;
        default:
                break;
@@ -1218,8 +1209,19 @@ static int sd_done(struct scsi_cmnd *SCpnt)
                sd_dif_complete(SCpnt, good_bytes);
 
        if (scsi_host_dif_capable(sdkp->device->host, sdkp->protection_type)
-           == SD_DIF_TYPE2_PROTECTION && SCpnt->cmnd != SCpnt->request->cmd)
+           == SD_DIF_TYPE2_PROTECTION && SCpnt->cmnd != SCpnt->request->cmd) {
+
+               /* We have to print a failed command here as the
+                * extended CDB gets freed before scsi_io_completion()
+                * is called.
+                */
+               if (result)
+                       scsi_print_command(SCpnt);
+
                mempool_free(SCpnt->cmnd, sd_cdb_pool);
+               SCpnt->cmnd = NULL;
+               SCpnt->cmd_len = 0;
+       }
 
        return good_bytes;
 }
@@ -1946,13 +1948,13 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
 {
        struct request_queue *q = sdkp->disk->queue;
        unsigned int sector_sz = sdkp->device->sector_size;
-       char *buffer;
+       const int vpd_len = 32;
+       unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL);
 
-       /* Block Limits VPD */
-       buffer = scsi_get_vpd_page(sdkp->device, 0xb0);
-
-       if (buffer == NULL)
-               return;
+       if (!buffer ||
+           /* Block Limits VPD */
+           scsi_get_vpd_page(sdkp->device, 0xb0, buffer, vpd_len))
+               goto out;
 
        blk_queue_io_min(sdkp->disk->queue,
                         get_unaligned_be16(&buffer[6]) * sector_sz);
@@ -1984,6 +1986,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
                                get_unaligned_be32(&buffer[32]) & ~(1 << 31);
        }
 
+ out:
        kfree(buffer);
 }
 
@@ -1993,20 +1996,23 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
  */
 static void sd_read_block_characteristics(struct scsi_disk *sdkp)
 {
-       char *buffer;
+       unsigned char *buffer;
        u16 rot;
+       const int vpd_len = 32;
 
-       /* Block Device Characteristics VPD */
-       buffer = scsi_get_vpd_page(sdkp->device, 0xb1);
+       buffer = kmalloc(vpd_len, GFP_KERNEL);
 
-       if (buffer == NULL)
-               return;
+       if (!buffer ||
+           /* Block Device Characteristics VPD */
+           scsi_get_vpd_page(sdkp->device, 0xb1, buffer, vpd_len))
+               goto out;
 
        rot = get_unaligned_be16(&buffer[4]);
 
        if (rot == 1)
                queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue);
 
+ out:
        kfree(buffer);
 }
 
@@ -2105,7 +2111,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
  *     which is followed by sdaaa.
  *
  *     This is basically 26 base counting with one extra 'nil' entry
- *     at the beggining from the second digit on and can be
+ *     at the beginning from the second digit on and can be
  *     determined using similar method as 26 base conversion with the
  *     index shifted -1 after each digit is computed.
  *
@@ -2179,7 +2185,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
        blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
 
        gd->driverfs_dev = &sdp->sdev_gendev;
-       gd->flags = GENHD_FL_EXT_DEVT | GENHD_FL_DRIVERFS;
+       gd->flags = GENHD_FL_EXT_DEVT;
        if (sdp->removable)
                gd->flags |= GENHD_FL_REMOVABLE;