Skip to contentSkip to conversation

ext2: check err when partial != NULL

PATCH In review Chengguang Xu 2 participants 2 messages Nov 5, 2019 ext2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext2: check err when partial != NULL

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

---
 fs/ext2/inode.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/ext2/inode.c +5 -2
index 7004ce581a32..a16c53655e77 100644
@@ -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;
+		}
 	}
 
 	/*
Signature · 1 line
2.20.1
#1 lore raw
Quoted 5 lines · Chengguang Xu

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

Good catch! Added to my tree. Thanks!

Honza

Quoted 29 lines
---
 fs/ext2/inode.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/ext2/inode.c +5 -2
index 7004ce581a32..a16c53655e77 100644
@@ -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;
+		}
 	}
 
 	/*
Signature · 1 line
2.20.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR