xfs: xfs_dabuf_map should return ENOMEM when map allocation fails
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 13 Mar 2020 20:17:40 +0000 (13:17 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Sun, 15 Mar 2020 16:22:35 +0000 (09:22 -0700)
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>
fs/xfs/libxfs/xfs_da_btree.c

index a7880c6285dbaf4dfc49f0d2f3f973d8e2ae1fd0..897749c41f36eb59b01750353defc8f7ada2517a 100644 (file)
@@ -2521,8 +2521,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;
        }