aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bottomley <jejb@mulgrave.(none)>2005-10-28 13:17:30 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2005-10-28 13:17:30 -0500
commit7a691bd34130920bef4d118a3f555ebc48544a63 (patch)
tree50b675e97e1525d2e07bf3c5bdc0098623768694
parentd578a4258bf674ef86b16bf29267fb302125aaee (diff)
[SCSI] avoid overflows in disk size calculations
Be more careful about doing the arithmetic in the non-LBD case. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r--drivers/scsi/sd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9a1dc0cea03..98da5c8057b 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1253,14 +1253,13 @@ got_data:
* Jacques Gelinas (Jacques@solucorp.qc.ca)
*/
int hard_sector = sector_size;
- sector_t sz = sdkp->capacity * (hard_sector/256);
+ sector_t sz = (sdkp->capacity/2) * (hard_sector/256);
request_queue_t *queue = sdp->request_queue;
- sector_t mb;
+ sector_t mb = sz;
blk_queue_hardsect_size(queue, hard_sector);
/* avoid 64-bit division on 32-bit platforms */
- mb = sz >> 1;
- sector_div(sz, 1250);
+ sector_div(sz, 625);
mb -= sz - 974;
sector_div(mb, 1950);