diff mbox series

ext2: check err when partial != NULL

Message ID 20191105045100.7104-1-cgxu519@mykernel.net
State Not Applicable
Headers show
Series ext2: check err when partial != NULL | expand

Commit Message

Chengguang Xu Nov. 5, 2019, 4:51 a.m. UTC
Check err when partial == NULL is meaningless because
partial == NULL means getting branch successfully without
error.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/ext2/inode.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jan Kara Nov. 5, 2019, 9:41 a.m. UTC | #1
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 <cgxu519@mykernel.net>

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
> 
> 
>
diff mbox series

Patch

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;
+		}
 	}
 
 	/*