From b91344f8566551d48c98f5c2d8d1b4a972b0dd3d Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Sat, 19 May 2012 03:42:57 +0000 Subject: [PATCH] Fix incorrect "Access beyond the end of the device" reporting for INQUIRY on vcdroms without disk Reported and suggested how to fix it by Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4309 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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,