mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-23 13:41:27 +00:00
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:
@@ -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]);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user