Commit 7a691bd3 authored by James Bottomley's avatar James Bottomley

[SCSI] avoid overflows in disk size calculations

Be more careful about doing the arithmetic in the non-LBD case.
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent d578a425
...@@ -1253,14 +1253,13 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname, ...@@ -1253,14 +1253,13 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
* Jacques Gelinas (Jacques@solucorp.qc.ca) * Jacques Gelinas (Jacques@solucorp.qc.ca)
*/ */
int hard_sector = sector_size; 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; request_queue_t *queue = sdp->request_queue;
sector_t mb; sector_t mb = sz;
blk_queue_hardsect_size(queue, hard_sector); blk_queue_hardsect_size(queue, hard_sector);
/* avoid 64-bit division on 32-bit platforms */ /* avoid 64-bit division on 32-bit platforms */
mb = sz >> 1; sector_div(sz, 625);
sector_div(sz, 1250);
mb -= sz - 974; mb -= sz - 974;
sector_div(mb, 1950); sector_div(mb, 1950);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment