scst: compute max_transfer args as long, not int

Compute max_transfer args as long, not int, to avoid overflow when
max_sg_cnt=32768 and PAGE_SHIFT=16 (64K PAGE_SIZE).  Note it is not
only the min() call, but also the << PAGE_SHIFT needs to be long.

Signed-off-by: David Butterfield <dab21774@gmail.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7189 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2017-05-20 02:04:16 +00:00
parent 8d3a9f440a
commit b3758b0db9

View File

@@ -4291,8 +4291,8 @@ static int vdisk_block_limits(uint8_t *buf, struct scst_cmd *cmd,
put_unaligned_be16(max_t(int, PAGE_SIZE / dev->block_size, 1), &buf[6]);
/* Max transfer len is min of sg limit and 8M */
max_transfer = min_t(int, cmd->tgt_dev->max_sg_cnt << PAGE_SHIFT,
8*1024*1024) / dev->block_size;
max_transfer = min((long)cmd->tgt_dev->max_sg_cnt << PAGE_SHIFT,
8*1024*1024l) / dev->block_size;
put_unaligned_be32(max_transfer, &buf[8]);
/*