From: Darrick J. Wong Date: Fri, 1 May 2020 21:37:09 +0000 (-0400) Subject: xfs: xfs_dabuf_map should return ENOMEM when map allocation fails X-Git-Tag: v5.7.0-rc0~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a2a0a99a70b02649250fe2c50ef9546f9e306d44;p=thirdparty%2Fxfsprogs-dev.git xfs: xfs_dabuf_map should return ENOMEM when map allocation fails Source kernel commit: faf8ee8476c19b30fd16079ad616b2b0f56eaff4 If the xfs_buf_map array allocation in xfs_dabuf_map fails for whatever reason, we bail out with error code zero. This will confuse callers, so make sure that we return ENOMEM. Allocation failure should never happen with the small size of the array, but code defensively anyway. Fixes: 45feef8f50b94d ("xfs: refactor xfs_dabuf_map") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index d785312fc..4e909caa9 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -2518,8 +2518,10 @@ xfs_dabuf_map( */ if (nirecs > 1) { map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map), KM_NOFS); - if (!map) + if (!map) { + error = -ENOMEM; goto out_free_irecs; + } *mapp = map; }