From: Andrei Vagin Date: Wed, 13 Dec 2017 21:55:13 +0000 (-0800) Subject: target: don't call an unmap callback if a range length is zero X-Git-Tag: v4.19~1595^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9960f85181dd08cda03fddcf0bc8d81190bec4eb;p=platform%2Fkernel%2Flinux-rpi.git target: don't call an unmap callback if a range length is zero If a length of a range is zero, it means there is nothing to unmap and we can skip this range. Here is one more reason, why we have to skip such ranges. An unmap callback calls file_operations->fallocate(), but the man page for the fallocate syscall says that fallocate(fd, mode, offset, let) returns EINVAL, if len is zero. It means that file_operations->fallocate() isn't obligated to handle zero ranges too. Signed-off-by: Andrei Vagin Signed-off-by: Nicholas Bellinger --- diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 750a04e..b054682 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -1216,9 +1216,11 @@ sbc_execute_unmap(struct se_cmd *cmd) goto err; } - ret = ops->execute_unmap(cmd, lba, range); - if (ret) - goto err; + if (range) { + ret = ops->execute_unmap(cmd, lba, range); + if (ret) + goto err; + } ptr += 16; size -= 16;