diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 1bfa90749..cadc2b196 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1189,8 +1189,12 @@ static bool vdisk_parse_offset(struct vdisk_cmd_params *p, struct scst_cmd *cmd) (long long unsigned int)lba_start, (long long unsigned int)loff, (long long unsigned int)data_len); - if (unlikely(loff < 0) || unlikely(data_len < 0) || - unlikely((loff + data_len) > virt_dev->file_size)) { + + EXTRACHECKS_BUG_ON((loff < 0) || unlikely(data_len < 0)); + + /* If lba_len is 0, loff doesn't make sense, so this error not possible */ + if (unlikely((loff + data_len) > virt_dev->file_size) && + (cmd->lba_len != 0)) { PRINT_INFO("Access beyond the end of the device " "(%lld of %lld, data len %lld)", (long long unsigned int)loff,