Skip to contentSkip to conversation

xfs: Fix uninitialized return value in xfs_alloc_fix_freelist()

PATCH In review Jan Kara 3 participants 3 messages Jul 15, 2015 – Aug 19, 2015 XFS filesystem

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 xfs: Fix uninitialized return value in xfs_alloc_fix_freelist()

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: [email protected]
Coverity-id: 1309714

---
 fs/xfs/libxfs/xfs_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
index f9e9ffe6fb46..7f8f2a0d4567 100644
@@ -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);
Signature · 6 lines
2.1.4

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · 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.

Quoted 7 lines

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

CC: [email protected]
Coverity-id: 1309714

---

Quoted 23 lines
 fs/xfs/libxfs/xfs_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -1
index f9e9ffe6fb46..7f8f2a0d4567 100644
@@ -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);
Signature · 6 lines
2.1.4

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 9 lines · Brian Foster
Quoted 8 lines · 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.

Quoted 6 lines
Quoted 4 lines

CC: [email protected]
Coverity-id: 1309714

---

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
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs