]> err.no Git - linux-2.6/commitdiff
[SCSI] avoid overflows in disk size calculations
authorJames Bottomley <jejb@mulgrave.(none)>
Fri, 28 Oct 2005 18:17:30 +0000 (13:17 -0500)
committerJames Bottomley <jejb@mulgrave.(none)>
Fri, 28 Oct 2005 18:17:30 +0000 (13:17 -0500)
Be more careful about doing the arithmetic in the non-LBD case.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/sd.c

index 9a1dc0cea03c374245ccfeebb5b8a095cab780d8..98da5c8057bfb5e28a121e3ed91acfa4c1d5cb97 100644 (file)
@@ -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);