udf: Fix off-by-one error when discarding preallocation

[ Upstream commit f54aa97fb7 ]

The condition determining whether the preallocation can be used had
an off-by-one error so we didn't discard preallocation when new
allocation was just following it. This can then confuse code in
inode_getblk().

CC: stable@vger.kernel.org
Fixes: 16d0556568 ("udf: Discard preallocation before extending file with a hole")
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jan Kara 2023-01-23 14:29:15 +01:00 коммит произвёл Greg Kroah-Hartman
Родитель 30e29af746
Коммит 31b5793ca2
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -442,7 +442,7 @@ static int udf_get_block(struct inode *inode, sector_t block,
* Block beyond EOF and prealloc extents? Just discard preallocation
* as it is not useful and complicates things.
*/
if (((loff_t)block) << inode->i_blkbits > iinfo->i_lenExtents)
if (((loff_t)block) << inode->i_blkbits >= iinfo->i_lenExtents)
udf_discard_prealloc(inode);
udf_clear_extent_cache(inode);
phys = inode_getblk(inode, block, &err, &new);