From: Dan Carpenter Date: Thu, 3 Aug 2023 10:29:34 +0000 (+0300) Subject: btrfs: fix some error checking for btrfs_decompress() X-Git-Tag: v2025.01-rc5-pxa1908~847^2~40^2~3 X-Git-Url: http://git.dujemihanovic.xyz/login.html?a=commitdiff_plain;h=08404fa2087946bb370430d466fe5011f18ef072;p=u-boot.git btrfs: fix some error checking for btrfs_decompress() The btrfs_decompress() function mostly (u32)-1 on error but it can also return -EPERM or other kernel error codes from zstd_decompress(). The "ret" variable is an int, so we could just check for negatives. Signed-off-by: Dan Carpenter Reviewed-by: Qu Wenruo --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 38e285bf94..4691612eda 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -390,7 +390,7 @@ int btrfs_read_extent_inline(struct btrfs_path *path, csize); ret = btrfs_decompress(btrfs_file_extent_compression(leaf, fi), cbuf, csize, dbuf, dsize); - if (ret == (u32)-1) { + if (ret < 0) { ret = -EIO; goto out; } @@ -500,7 +500,7 @@ int btrfs_read_extent_reg(struct btrfs_path *path, ret = btrfs_decompress(btrfs_file_extent_compression(leaf, fi), cbuf, csize, dbuf, dsize); - if (ret == (u32)-1) { + if (ret < 0) { ret = -EIO; goto out; }