summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2017-07-17 17:30:57 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2017-07-20 17:42:33 -0400
commit10479e2dea83d4c421ad05dfc55d918aa8dfc0cd (patch)
tree65bd2a8994345c5b793541206f54a15bf56903a9 /fs
parent4c1a67bd3606540b9b42caff34a1d5cd94b1cf65 (diff)
xfs: check _alloc_read_agf buffer pointer before using
In some circumstances, _alloc_read_agf can return an error code of zero but also a null AGF buffer pointer. Check for this and jump out. Fixes-coverity-id: 1415250 Fixes-coverity-id: 1415320 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_refcount.c4
-rw-r--r--fs/xfs/xfs_reflink.c2
2 files changed, 6 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 900ea231f9a3..45b1c3b4e047 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1638,6 +1638,10 @@ xfs_refcount_recover_cow_leftovers(
1638 error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp); 1638 error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
1639 if (error) 1639 if (error)
1640 goto out_trans; 1640 goto out_trans;
1641 if (!agbp) {
1642 error = -ENOMEM;
1643 goto out_trans;
1644 }
1641 cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL); 1645 cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
1642 1646
1643 /* Find all the leftover CoW staging extents. */ 1647 /* Find all the leftover CoW staging extents. */
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index d9b3d57a1921..f45fbf0db9bb 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -170,6 +170,8 @@ xfs_reflink_find_shared(
170 error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp); 170 error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
171 if (error) 171 if (error)
172 return error; 172 return error;
173 if (!agbp)
174 return -ENOMEM;
173 175
174 cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL); 176 cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
175 177