public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: Fix uninitialized return value in xfs_alloc_fix_freelist()
@ 2015-07-15  8:16 Jan Kara
  2015-07-15 11:16 ` Brian Foster
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2015-07-15  8:16 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs, Jan Kara

xfs_alloc_fix_freelist() can sometimes jump to out_agbp_relse without
ever setting value of 'error' variable which is then returned. This can
happen e.g. when pag->pagf_init is set but AG is for metadata and we
want to allocate user data.

Fix the problem by initializing 'error' to 0, which is the desired
return value when we decide to skip this group.

CC: xfs@oss.sgi.com
Coverity-id: 1309714
Signed-off-by: Jan Kara <jack@suse.com>
---
 fs/xfs/libxfs/xfs_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index f9e9ffe6fb46..7f8f2a0d4567 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1937,7 +1937,7 @@ xfs_alloc_fix_freelist(
 	struct xfs_alloc_arg	targs;	/* local allocation arguments */
 	xfs_agblock_t		bno;	/* freelist block */
 	xfs_extlen_t		need;	/* total blocks needed in freelist */
-	int			error;
+	int			error = 0;
 
 	if (!pag->pagf_init) {
 		error = xfs_alloc_read_agf(mp, tp, args->agno, flags, &agbp);
-- 
2.1.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: Fix uninitialized return value in xfs_alloc_fix_freelist()
  2015-07-15  8:16 [PATCH] xfs: Fix uninitialized return value in xfs_alloc_fix_freelist() Jan Kara
@ 2015-07-15 11:16 ` Brian Foster
  2015-08-19 17:40   ` Eric Sandeen
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Foster @ 2015-07-15 11:16 UTC (permalink / raw)
  To: Jan Kara; +Cc: xfs

On Wed, Jul 15, 2015 at 10:16:08AM +0200, Jan Kara wrote:
> xfs_alloc_fix_freelist() can sometimes jump to out_agbp_relse without
> ever setting value of 'error' variable which is then returned. This can
> happen e.g. when pag->pagf_init is set but AG is for metadata and we
> want to allocate user data.
> 
> Fix the problem by initializing 'error' to 0, which is the desired
> return value when we decide to skip this group.
> 
> CC: xfs@oss.sgi.com
> Coverity-id: 1309714
> Signed-off-by: Jan Kara <jack@suse.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_alloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index f9e9ffe6fb46..7f8f2a0d4567 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -1937,7 +1937,7 @@ xfs_alloc_fix_freelist(
>  	struct xfs_alloc_arg	targs;	/* local allocation arguments */
>  	xfs_agblock_t		bno;	/* freelist block */
>  	xfs_extlen_t		need;	/* total blocks needed in freelist */
> -	int			error;
> +	int			error = 0;
>  
>  	if (!pag->pagf_init) {
>  		error = xfs_alloc_read_agf(mp, tp, args->agno, flags, &agbp);
> -- 
> 2.1.4
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: Fix uninitialized return value in xfs_alloc_fix_freelist()
  2015-07-15 11:16 ` Brian Foster
@ 2015-08-19 17:40   ` Eric Sandeen
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2015-08-19 17:40 UTC (permalink / raw)
  To: Brian Foster, Jan Kara; +Cc: xfs

On 7/15/15 6:16 AM, Brian Foster wrote:
> On Wed, Jul 15, 2015 at 10:16:08AM +0200, Jan Kara wrote:
>> xfs_alloc_fix_freelist() can sometimes jump to out_agbp_relse without
>> ever setting value of 'error' variable which is then returned. This can
>> happen e.g. when pag->pagf_init is set but AG is for metadata and we
>> want to allocate user data.
>>
>> Fix the problem by initializing 'error' to 0, which is the desired
>> return value when we decide to skip this group.
>>
>> CC: xfs@oss.sgi.com
>> Coverity-id: 1309714
>> Signed-off-by: Jan Kara <jack@suse.com>
>> ---
> 
> Reviewed-by: Brian Foster <bfoster@redhat.com>

Dave, ping on this one?  I don't see it in your latest update, looks important.
(xfsprogs has the same problem, FWIW)

-Eric

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-19 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-15  8:16 [PATCH] xfs: Fix uninitialized return value in xfs_alloc_fix_freelist() Jan Kara
2015-07-15 11:16 ` Brian Foster
2015-08-19 17:40   ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox