From d705962a19dc6b3e8db9530b6f7571ea0220682f Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 31 Jul 2017 15:08:13 -0500 Subject: [PATCH] xfs: check _alloc_read_agf buffer pointer before using Source kernel commit: 10479e2dea83d4c421ad05dfc55d918aa8dfc0cd 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 Reviewed-by: Brian Foster Signed-off-by: Eric Sandeen --- libxfs/xfs_refcount.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c index 52ec20c74..3e0c81523 100644 --- a/libxfs/xfs_refcount.c +++ b/libxfs/xfs_refcount.c @@ -1637,6 +1637,10 @@ xfs_refcount_recover_cow_leftovers( error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp); if (error) goto out_trans; + if (!agbp) { + error = -ENOMEM; + goto out_trans; + } cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL); /* Find all the leftover CoW staging extents. */ -- 2.47.2