diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/sd.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 51a5557f42dd..37df8bbe7f46 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -929,6 +929,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) | |||
929 | unsigned int xfer_size = scsi_bufflen(SCpnt); | 929 | unsigned int xfer_size = scsi_bufflen(SCpnt); |
930 | unsigned int good_bytes = result ? 0 : xfer_size; | 930 | unsigned int good_bytes = result ? 0 : xfer_size; |
931 | u64 start_lba = SCpnt->request->sector; | 931 | u64 start_lba = SCpnt->request->sector; |
932 | u64 end_lba = SCpnt->request->sector + (xfer_size / 512); | ||
932 | u64 bad_lba; | 933 | u64 bad_lba; |
933 | struct scsi_sense_hdr sshdr; | 934 | struct scsi_sense_hdr sshdr; |
934 | int sense_valid = 0; | 935 | int sense_valid = 0; |
@@ -967,26 +968,23 @@ static int sd_done(struct scsi_cmnd *SCpnt) | |||
967 | goto out; | 968 | goto out; |
968 | if (xfer_size <= SCpnt->device->sector_size) | 969 | if (xfer_size <= SCpnt->device->sector_size) |
969 | goto out; | 970 | goto out; |
970 | switch (SCpnt->device->sector_size) { | 971 | if (SCpnt->device->sector_size < 512) { |
971 | case 256: | 972 | /* only legitimate sector_size here is 256 */ |
972 | start_lba <<= 1; | 973 | start_lba <<= 1; |
973 | break; | 974 | end_lba <<= 1; |
974 | case 512: | 975 | } else { |
975 | break; | 976 | /* be careful ... don't want any overflows */ |
976 | case 1024: | 977 | u64 factor = SCpnt->device->sector_size / 512; |
977 | start_lba >>= 1; | 978 | do_div(start_lba, factor); |
978 | break; | 979 | do_div(end_lba, factor); |
979 | case 2048: | ||
980 | start_lba >>= 2; | ||
981 | break; | ||
982 | case 4096: | ||
983 | start_lba >>= 3; | ||
984 | break; | ||
985 | default: | ||
986 | /* Print something here with limiting frequency. */ | ||
987 | goto out; | ||
988 | break; | ||
989 | } | 980 | } |
981 | |||
982 | if (bad_lba < start_lba || bad_lba >= end_lba) | ||
983 | /* the bad lba was reported incorrectly, we have | ||
984 | * no idea where the error is | ||
985 | */ | ||
986 | goto out; | ||
987 | |||
990 | /* This computation should always be done in terms of | 988 | /* This computation should always be done in terms of |
991 | * the resolution of the device's medium. | 989 | * the resolution of the device's medium. |
992 | */ | 990 | */ |