mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-18 13:16:34 +00:00
scst_vdisk: Fix a Coverity complaint about integer overflow
Fix the following Coverity complaint: CID 347914 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially overflowing expression blocks << cmd->dev->block_shift - 9 with type uint32_t (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type sector_t (64 bits, unsigned). To avoid overflow, cast blocks to type sector_t. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8566 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -1825,7 +1825,7 @@ static int vdisk_unmap_file_range(struct scst_cmd *cmd,
|
||||
}
|
||||
|
||||
static int vdisk_unmap_range(struct scst_cmd *cmd,
|
||||
struct scst_vdisk_dev *virt_dev, uint64_t start_lba, uint32_t blocks)
|
||||
struct scst_vdisk_dev *virt_dev, uint64_t start_lba, uint64_t blocks)
|
||||
{
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27)
|
||||
int res, err;
|
||||
@@ -1850,7 +1850,7 @@ static int vdisk_unmap_range(struct scst_cmd *cmd,
|
||||
}
|
||||
|
||||
TRACE_DBG("Unmapping lba %lld (blocks %lld)",
|
||||
(unsigned long long)start_lba, (unsigned long long)blocks);
|
||||
(unsigned long long)start_lba, blocks);
|
||||
|
||||
if (virt_dev->blockio) {
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27)
|
||||
@@ -1874,7 +1874,7 @@ static int vdisk_unmap_range(struct scst_cmd *cmd,
|
||||
#endif
|
||||
if (unlikely(err != 0)) {
|
||||
PRINT_ERROR("blkdev_issue_discard() for "
|
||||
"LBA %lld, blocks %d failed: %d",
|
||||
"LBA %lld, blocks %lld failed: %d",
|
||||
(unsigned long long)start_lba, blocks, err);
|
||||
scst_set_cmd_error(cmd,
|
||||
SCST_LOAD_SENSE(scst_sense_write_error));
|
||||
@@ -1888,7 +1888,7 @@ static int vdisk_unmap_range(struct scst_cmd *cmd,
|
||||
#endif
|
||||
} else {
|
||||
loff_t off = start_lba << cmd->dev->block_shift;
|
||||
loff_t len = (u64)blocks << cmd->dev->block_shift;
|
||||
loff_t len = blocks << cmd->dev->block_shift;
|
||||
|
||||
res = vdisk_unmap_file_range(cmd, virt_dev, off, len, fd);
|
||||
if (unlikely(res != 0))
|
||||
|
||||
Reference in New Issue
Block a user