]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: null out bma->prev if no previous extent
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 22 Jan 2020 16:29:40 +0000 (11:29 -0500)
Source kernel commit: f5be08446ee748785697527c8d772d896814b95f

Coverity complains that we don't check the return value of
xfs_iext_peek_prev_extent like we do nearly all of the time.  If there
is no previous extent then just null out bma->prev like we do elsewhere
in the bmap code.

Coverity-id: 1424057
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_bmap.c

index bd117a30a06e416050953abf75bbee1629b34f0d..b1edc10d17ead7cbe4375ca14c8405bd6fef6934 100644 (file)
@@ -4006,7 +4006,8 @@ xfs_bmapi_allocate(
        if (bma->wasdel) {
                bma->length = (xfs_extlen_t)bma->got.br_blockcount;
                bma->offset = bma->got.br_startoff;
-               xfs_iext_peek_prev_extent(ifp, &bma->icur, &bma->prev);
+               if (!xfs_iext_peek_prev_extent(ifp, &bma->icur, &bma->prev))
+                       bma->prev.br_startoff = NULLFILEOFF;
        } else {
                bma->length = XFS_FILBLKS_MIN(bma->length, MAXEXTLEN);
                if (!bma->eof)