[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1582654986.7365.120.camel@lca.pw>
Date: Tue, 25 Feb 2020 13:23:06 -0500
From: Qian Cai <cai@....pw>
To: Christoph Hellwig <hch@...radead.org>
Cc: darrick.wong@...cle.com, linux-xfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] xfs: fix an undefined behaviour in _da3_path_shift
On Tue, 2020-02-25 at 10:07 -0800, Christoph Hellwig wrote:
> I think we code do this a tad more cleaner, something like:
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 875e04f82541..542a4edfcf54 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -1986,7 +1986,8 @@ xfs_da3_path_shift(
> ASSERT(path != NULL);
> ASSERT((path->active > 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
> level = (path->active-1) - 1; /* skip bottom layer in path */
> - for (blk = &path->blk[level]; level >= 0; blk--, level--) {
> + for ( ; level >= 0; level--) {
> + blk = &path->blk[level];
> xfs_da3_node_hdr_from_disk(dp->i_mount, &nodehdr,
> blk->bp->b_addr);
>
Yes, indeed. I'll send a v2 until Darrick is still not convinced that
"path->active == 1" could reach here?
Powered by blists - more mailing lists