]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: xfs_dabuf_map should return ENOMEM when map allocation fails
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)
committerEric Sandeen <sandeen@redhat.com>
Fri, 1 May 2020 21:37:09 +0000 (17:37 -0400)
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 <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_da_btree.c

index d785312fc27fc172b452ac32823b48055a737b0b..4e909caa954a116fc99f49d39f0cc2cdf6e6f7e6 100644 (file)
@@ -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;
        }