U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix some error checking for btrfs_decompress()
@ 2023-08-03 10:29 Dan Carpenter
  2023-08-03 10:36 ` Qu Wenruo
  2023-08-09  1:40 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-08-03 10:29 UTC (permalink / raw)
  To: Marek Behún; +Cc: Qu Wenruo, u-boot

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>
---
 fs/btrfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 38e285bf94b0..4691612eda33 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;
 	}
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix some error checking for btrfs_decompress()
  2023-08-03 10:29 [PATCH] btrfs: fix some error checking for btrfs_decompress() Dan Carpenter
@ 2023-08-03 10:36 ` Qu Wenruo
  2023-08-09  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2023-08-03 10:36 UTC (permalink / raw)
  To: u-boot



On 2023/8/3 18:29, Dan Carpenter wrote:
> 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>

Thanks,
Qu
> ---
>   fs/btrfs/inode.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 38e285bf94b0..4691612eda33 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;
>   	}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix some error checking for btrfs_decompress()
  2023-08-03 10:29 [PATCH] btrfs: fix some error checking for btrfs_decompress() Dan Carpenter
  2023-08-03 10:36 ` Qu Wenruo
@ 2023-08-09  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-08-09  1:40 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Marek Behún, Qu Wenruo, u-boot

[-- Attachment #1: Type: text/plain, Size: 432 bytes --]

On Thu, Aug 03, 2023 at 01:29:34PM +0300, Dan Carpenter wrote:

> 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>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-09  1:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 10:29 [PATCH] btrfs: fix some error checking for btrfs_decompress() Dan Carpenter
2023-08-03 10:36 ` Qu Wenruo
2023-08-09  1:40 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox