]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
btrfs: fix some error checking for btrfs_decompress()
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 3 Aug 2023 10:29:34 +0000 (13:29 +0300)
committerTom Rini <trini@konsulko.com>
Tue, 8 Aug 2023 21:41:52 +0000 (17:41 -0400)
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 <dan.carpenter@linaro.org>
Reviewed-by: Qu Wenruo <wqu@suse.com>
fs/btrfs/inode.c

index 38e285bf94b02cafce3acdc38336810cbadf058f..4691612eda338589ec803d93a7a017f20bd9838b 100644 (file)
@@ -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;
        }