Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1501850

[PATCH] xfs: Fix uninitialized variable in xfs_reflink_reserve_cow_range()

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Geert Uytterhoeven <geert@linux-m68k.org>
Newsgroups linux.kernel
Subject [PATCH] xfs: Fix uninitialized variable in xfs_reflink_reserve_cow_range()
Date Mon, 17 Oct 2016 12:20:02 +0200
Message-ID <stdbs-2aY-19@gated-at.bofh.it> (permalink)
X-Mailer git-send-email 1.9.1
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 32
Organization linux.* mail to news gateway
X-Original-Cc linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert@linux-m68k.org>
X-Original-Date Mon, 17 Oct 2016 12:16:44 +0200
X-Original-Message-ID <1476699404-5977-1-git-send-email-geert@linux-m68k.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1501850

Show key headers only | View raw


with gcc 4.1.2:

    fs/xfs/xfs_reflink.c: In function ‘xfs_reflink_reserve_cow_range’:
    fs/xfs/xfs_reflink.c:327: warning: ‘error’ may be used uninitialized in this function

Indeed, if "count" is zero, the function will return an uninitialized
error value.

While "count" is unlikely to be zero, this function is called through
the public iomap API. Hence fix this by preinitializing error to zero.

Fixes: 2a06705cd5954030 ("xfs: create delalloc extents in CoW fork")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 fs/xfs/xfs_reflink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 5965e9455d91e036..d48a7cc2fe007f66 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -324,7 +324,7 @@
 	struct xfs_mount	*mp = ip->i_mount;
 	xfs_fileoff_t		offset_fsb, end_fsb;
 	bool			skipped = false;
-	int			error;
+	int			error = 0;
 
 	trace_xfs_reflink_reserve_cow_range(ip, offset, count);
 
-- 
1.9.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] xfs: Fix uninitialized variable in xfs_reflink_reserve_cow_range() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-17 12:20 +0200
  Re: [PATCH] xfs: Fix uninitialized variable in  xfs_reflink_reserve_cow_range() Christoph Hellwig <hch@infradead.org> - 2016-10-17 14:10 +0200
    Re: [PATCH] xfs: Fix uninitialized variable in xfs_reflink_reserve_cow_range() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-17 14:20 +0200
  Re: [PATCH] xfs: Fix uninitialized variable in  xfs_reflink_reserve_cow_range() "Darrick J. Wong" <darrick.wong@oracle.com> - 2016-10-17 20:40 +0200

csiph-web