Skip to contentSkip to conversation

udf: Fix inode_getblk() return value

PATCH In review Jan Kara 2 participants 3 messages Mar 12, 2025 – Mar 13, 2025

Subsystems (3)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 udf: Fix inode_getblk() return value

Smatch noticed that inode_getblk() can return 1 on successful mapping of a block instead of expected 0 after commit b405c1e58b73 ("udf: refactor udf_next_aext() to handle error"). This could confuse some of the callers and lead to strange failures (although the one reported by Smatch in udf_mkdir() is impossible to trigger in practice). Fix the return value of inode_getblk().

Fixes b405c1e58b73 ("udf: refactor udf_next_aext() to handle error")
---
 fs/udf/inode.c | 1 +
 1 file changed, 1 insertion(+)

I plan to merge this patch through my tree.

fs/udf/inode.c +1 -0
index 70c907fe8af9..4386dd845e40 100644
@@ -810,6 +810,7 @@ static int inode_getblk(struct inode *inode, struct udf_map_rq *map)
 		}
 		map->oflags = UDF_BLK_MAPPED;
 		map->pblk = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
+		ret = 0;
 		goto out_free;
 	}
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Jan Kara

Smatch noticed that inode_getblk() can return 1 on successful mapping of a block instead of expected 0 after commit b405c1e58b73 ("udf: refactor udf_next_aext() to handle error"). This could confuse some of the callers and lead to strange failures (although the one reported by Smatch in udf_mkdir() is impossible to trigger in practice). Fix the return value of inode_getblk().

Fixes b405c1e58b73 ("udf: refactor udf_next_aext() to handle error")
---
 fs/udf/inode.c | 1 +
 1 file changed, 1 insertion(+)

I plan to merge this patch through my tree.

fs/udf/inode.c +0 -0
index 70c907fe8af9..4386dd845e40 100644

fs/udf/inode.c static int inode_getblk(struct inode *inode, struct udf_map_rq *map) · line 816

Quoted 7 lines
fs/udf/inode.c +1 -0
@@ -810,6 +810,7 @@ static int inode_getblk(struct inode *inode, struct udf_map_rq *map)
 		}
 		map->oflags = UDF_BLK_MAPPED;
 		map->pblk = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
+		ret = 0;
 		goto out_free;
 	}
 
Quoted 4 lines

--
2.43.0

author reviewer
#2 lore raw
Quoted 19 lines · Carlos Maiolino
Quoted 18 lines · Jan Kara

Smatch noticed that inode_getblk() can return 1 on successful mapping of a block instead of expected 0 after commit b405c1e58b73 ("udf: refactor udf_next_aext() to handle error"). This could confuse some of the callers and lead to strange failures (although the one reported by Smatch in udf_mkdir() is impossible to trigger in practice). Fix the return value of inode_getblk().

Fixes b405c1e58b73 ("udf: refactor udf_next_aext() to handle error")
---
 fs/udf/inode.c | 1 +
 1 file changed, 1 insertion(+)

I plan to merge this patch through my tree.

Quoted 14 lines

fs/udf/inode.c static int inode_getblk(struct inode *inode, struct udf_map_rq *map) · line 816

Quoted 12 lines
fs/udf/inode.c +1 -0
index 70c907fe8af9..4386dd845e40 100644
@@ -810,6 +810,7 @@ static int inode_getblk(struct inode *inode, struct udf_map_rq *map)
 		}
 		map->oflags = UDF_BLK_MAPPED;
 		map->pblk = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
+		ret = 0;
 		goto out_free;
 	}
 

Thanks. Picked up.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR