Skip to contentSkip to conversation

SCSI: Change size of factor from u64 to unsigned int.

PATCH New Ralf Baechle 1 participant 1 message Dec 22, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SCSI: Change size of factor from u64 to unsigned int.

Struct scsi_device.sector_size is unsigned int, so the value of factor can have at most 23 significant bits.

Adding a type check to do_div() caught these two do_div as the only invocations in the kernel passing a non-32-bit divisor.

---
 drivers/scsi/sd.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +1 -2
index fa3a591..42a1ff6 100644
@@ -1335,8 +1335,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
 		start_lba <<= 1;
 		end_lba <<= 1;
 	} else {
-		/* be careful ... don't want any overflows */
-		u64 factor = scmd->device->sector_size / 512;
+		unsigned int factor = scmd->device->sector_size / 512;
 		do_div(start_lba, factor);
 		do_div(end_lba, factor);
 	}