xfs-masters
[Top] [All Lists]

[xfs-masters] Re: [PATCH] Uninitialized variable

To: xfs-masters@xxxxxxxxxxx
Subject: [xfs-masters] Re: [PATCH] Uninitialized variable
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Fri, 04 Jul 2008 12:24:19 -0500
Cc: xfs@xxxxxxxxxxx
In-reply-to: <486DDF71.8030109@xxxxxxxxxxxxxx>
References: <486DDF71.8030109@xxxxxxxxxxxxxx>
Reply-to: xfs-masters@xxxxxxxxxxx
Sender: xfs-masters-bounce@xxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)
Wang Chen wrote:
> If the following loop doesn't execute, "tp" will be an
> uninitialized variable before being used.
> -
>       for (bmbno = sbp->sb_rbmblocks -
>                    ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0);
> -
> 
> Signed-off-by: Wang Chen <wangchen@xxxxxxxxxxxxxx>
> ---
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index a0dc6e5..f1ab0ca 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -1882,6 +1882,7 @@ xfs_growfs_rt(
>  
>       sbp = &mp->m_sb;
>       cancelflags = 0;
> +     tp = NULL;
>       /*
>        * Initial error checking.
>        */
> 
> 

I think that in practice it's ok because the user is:

        if (error && tp)
                xfs_trans_cancel(tp, cancelflags);

which is outside the loop, and error cannot be set unless the loop was
executed (any previous set of error immediately returns).

Still, the patch is probably a good thing to have.

-Eric


<Prev in Thread] Current Thread [Next in Thread>