From: Dave Chinner Date: Fri, 15 Oct 2021 20:28:27 +0000 (-0400) Subject: xfs: perag may be null in xfs_imap() X-Git-Tag: libxfs-5.14-sync_2021-10-16~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e86bc63fa6f4078da8094d225d9bfb8ddd16232c;p=thirdparty%2Fxfsprogs-dev.git xfs: perag may be null in xfs_imap() Source kernel commit: 90e2c1c20ac672756a2835b5a92a606dd48a4aa3 Dan Carpenter's static checker reported: The patch 7b13c5155182: "xfs: use perag for ialloc btree cursors" from Jun 2, 2021, leads to the following Smatch complaint: fs/xfs/libxfs/xfs_ialloc.c:2403 xfs_imap() error: we previously assumed 'pag' could be null (see line 2294) And it's right. Fix it. Fixes: 7b13c5155182 ("xfs: use perag for ialloc btree cursors") Reported-by: Dan Carpenter Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index d14437bfd..4d297a902 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -2393,7 +2393,8 @@ out_map: } error = 0; out_drop: - xfs_perag_put(pag); + if (pag) + xfs_perag_put(pag); return error; }