diff mbox series

udf: Fix inode_getblk() return value

Message ID 20250312163846.22851-2-jack@suse.cz (mailing list archive)
State New
Headers show
Series udf: Fix inode_getblk() return value | expand

Commit Message

Jan Kara March 12, 2025, 4:38 p.m. UTC
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>
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 | 1 +
 1 file changed, 1 insertion(+)

I plan to merge this patch through my tree.

Comments

Carlos Maiolino March 13, 2025, 10:13 a.m. UTC | #1
On Wed, Mar 12, 2025 at 05:38:47PM +0100, Jan Kara wrote:
> 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>
> 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 | 1 +
>  1 file changed, 1 insertion(+)
> 
> I plan to merge this patch through my tree.
> 
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 70c907fe8af9..4386dd845e40 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -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;
>  	}
> 

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> --
> 2.43.0
> 
>
Jan Kara March 13, 2025, 5:25 p.m. UTC | #2
On Thu 13-03-25 11:13:45, Carlos Maiolino wrote:
> On Wed, Mar 12, 2025 at 05:38:47PM +0100, Jan Kara wrote:
> > 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>
> > 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 | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > I plan to merge this patch through my tree.
> > 
> > diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> > index 70c907fe8af9..4386dd845e40 100644
> > --- a/fs/udf/inode.c
> > +++ b/fs/udf/inode.c
> > @@ -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;
> >  	}
> > 
> 
> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

Thanks. Picked up.

								Honza
diff mbox series

Patch

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 70c907fe8af9..4386dd845e40 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -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;
 	}