linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>,
	linux-xfs@vger.kernel.org, Dave Chinner <dchinner@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] xfs: scrub: avoid uninitialized return code
Date: Thu, 2 Nov 2017 08:44:00 -0400	[thread overview]
Message-ID: <20171102124359.GB16645@bfoster.bfoster> (raw)
In-Reply-To: <20171102111137.3062126-1-arnd@arndb.de>

On Thu, Nov 02, 2017 at 12:11:12PM +0100, Arnd Bergmann wrote:
> The newly added xfs_scrub_da_btree_block() function has one code path
> that returns the 'error' variable without initializing it first, as
> shown by this compiler warning:
> 
> fs/xfs/scrub/dabtree.c: In function 'xfs_scrub_da_btree_block':
> fs/xfs/scrub/dabtree.c:462:9: error: 'error' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> Returning -EINVAL might be an appropriate return code in this case.
> 
> Fixes: 7c4a07a424c1 ("xfs: scrub directory/attribute btrees")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  fs/xfs/scrub/dabtree.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
> index 4a93cf1753d3..971566388c9a 100644
> --- a/fs/xfs/scrub/dabtree.c
> +++ b/fs/xfs/scrub/dabtree.c
> @@ -349,8 +349,10 @@ xfs_scrub_da_btree_block(
>  
>  	/* Check the pointer. */
>  	blk->blkno = blkno;
> -	if (!xfs_scrub_da_btree_ptr_ok(ds, level, blkno))
> +	if (!xfs_scrub_da_btree_ptr_ok(ds, level, blkno)) {
> +		error = -EINVAL;
>  		goto out_nobuf;
> +	}

Hmm.. is an error really the right thing to do here vs. setting the
context corrupt and returning 0? (Darrick..?) If the latter, perhaps
error should just be initialized to 0.

Brian

>  
>  	/* Read the buffer. */
>  	error = xfs_da_read_buf(dargs->trans, dargs->dp, blk->blkno, -2,
> -- 
> 2.9.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-11-02 12:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 11:11 [PATCH 1/2] xfs: scrub: avoid uninitialized return code Arnd Bergmann
2017-11-02 11:11 ` [PATCH 2/2] xfs: fix unused variable warnings Arnd Bergmann
2017-11-02 12:44   ` Brian Foster
2017-11-02 16:52     ` Darrick J. Wong
2017-11-02 12:44 ` Brian Foster [this message]
2017-11-02 16:49   ` [PATCH 1/2] xfs: scrub: avoid uninitialized return code Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171102124359.GB16645@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=arnd@arndb.de \
    --cc=darrick.wong@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).