udf: Fix inode_getblk() return value
authorJan Kara <jack@suse.cz>
Wed, 12 Mar 2025 15:18:39 +0000 (16:18 +0100)
committerJan Kara <jack@suse.cz>
Thu, 13 Mar 2025 17:23:29 +0000 (18:23 +0100)
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().

Link: https://lore.kernel.org/all/cb514af7-bbe0-435b-934f-dd1d7a16d2cd@stanley.mountain
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Fixes: b405c1e58b73 ("udf: refactor udf_next_aext() to handle error")
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
fs/udf/inode.c

index 70c907fe8af9eb742e510163f1c23c54b87a2108..4386dd845e40097da75ba8325a12d5c69a37ad36 100644 (file)
@@ -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;
        }