2019-11-05 04:52:07

by Chengguang Xu

[permalink] [raw]
Subject: [PATCH] ext2: check err when partial != NULL

Check err when partial == NULL is meaningless because
partial == NULL means getting branch successfully without
error.

Signed-off-by: Chengguang Xu <[email protected]>
---
fs/ext2/inode.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 7004ce581a32..a16c53655e77 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -701,10 +701,13 @@ static int ext2_get_blocks(struct inode *inode,
if (!partial) {
count++;
mutex_unlock(&ei->truncate_mutex);
- if (err)
- goto cleanup;
goto got_it;
}
+
+ if (err) {
+ mutex_unlock(&ei->truncate_mutex);
+ goto cleanup;
+ }
}

/*
--
2.20.1




2019-11-05 09:42:41

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] ext2: check err when partial != NULL

On Tue 05-11-19 12:51:00, Chengguang Xu wrote:
> Check err when partial == NULL is meaningless because
> partial == NULL means getting branch successfully without
> error.
>
> Signed-off-by: Chengguang Xu <[email protected]>

Good catch! Added to my tree. Thanks!

Honza

> ---
> fs/ext2/inode.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index 7004ce581a32..a16c53655e77 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -701,10 +701,13 @@ static int ext2_get_blocks(struct inode *inode,
> if (!partial) {
> count++;
> mutex_unlock(&ei->truncate_mutex);
> - if (err)
> - goto cleanup;
> goto got_it;
> }
> +
> + if (err) {
> + mutex_unlock(&ei->truncate_mutex);
> + goto cleanup;
> + }
> }
>
> /*
> --
> 2.20.1
>
>
>
--
Jan Kara <[email protected]>
SUSE Labs, CR