Skip to contentSkip to conversation

ext4: Fix an IS_ERR() vs NULL check

PATCH In review Dan Carpenter 3 participants 3 messages Oct 23, 2020 – Dec 13, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Fix an IS_ERR() vs NULL check

The ext4_find_extent() function never returns NULL, it returns error pointers.

Fixes 44059e503b03 ("ext4: fast commit recovery path")
---
 fs/ext4/extents.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/extents.c +2 -2
index 6b33b9c86b00..a19d0e3a4126 100644
@@ -5820,8 +5820,8 @@ int ext4_ext_replay_update_ex(struct inode *inode, ext4_lblk_t start,
 	int ret;
 
 	path = ext4_find_extent(inode, start, NULL, 0);
-	if (!path)
-		return -EINVAL;
+	if (IS_ERR(path))
+		return PTR_ERR(path);
 	ex = path[path->p_depth].p_ext;
 	if (!ex) {
 		ret = -EFSCORRUPTED;
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

The ext4_find_extent() function never returns NULL, it returns error pointers.

Fixes 44059e503b03 ("ext4: fast commit recovery path")

I think this fix has fallen through the cracks? It looks good to me so feel free to add:

Honza

Quoted 22 lines
---
 fs/ext4/extents.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/extents.c +2 -2
index 6b33b9c86b00..a19d0e3a4126 100644
@@ -5820,8 +5820,8 @@ int ext4_ext_replay_update_ex(struct inode *inode, ext4_lblk_t start,
 	int ret;
 
 	path = ext4_find_extent(inode, start, NULL, 0);
-	if (!path)
-		return -EINVAL;
+	if (IS_ERR(path))
+		return PTR_ERR(path);
 	ex = path[path->p_depth].p_ext;
 	if (!ex) {
 		ret = -EFSCORRUPTED;
Signature · 1 line
2.28.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer
#2 lore raw
Quoted 11 lines · Jan Kara
Quoted 5 lines · Dan Carpenter

The ext4_find_extent() function never returns NULL, it returns error pointers.

Fixes 44059e503b03 ("ext4: fast commit recovery path")

I think this fix has fallen through the cracks? It looks good to me so feel free to add:

This had indeed slipped through the cracks. Thanks for pointing it out; I've applied it.

- Ted