diff mbox series

[-next] btrfs: Fix return value while kcalloc fails in btrfs_rmap_block

Message ID 20200115142027.56960-1-yuehaibing@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] btrfs: Fix return value while kcalloc fails in btrfs_rmap_block | expand

Commit Message

Yue Haibing Jan. 15, 2020, 2:20 p.m. UTC
In btrfs_rmap_block(), if kcalloc fails, it should return
-ENOMEM instead of 0.

Fixes: 767f58cdaf20 ("btrfs: Refactor btrfs_rmap_block to improve readability")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 fs/btrfs/block-group.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba Jan. 15, 2020, 4:05 p.m. UTC | #1
On Wed, Jan 15, 2020 at 10:20:27PM +0800, YueHaibing wrote:
> In btrfs_rmap_block(), if kcalloc fails, it should return
> -ENOMEM instead of 0.
> 
> Fixes: 767f58cdaf20 ("btrfs: Refactor btrfs_rmap_block to improve readability")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Thanks, folded to the patch.
diff mbox series

Patch

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 8877af5..1485158 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1655,7 +1655,7 @@  int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start,
 	*stripe_len = io_stripe_size;
 out:
 	free_extent_map(em);
-	return 0;
+	return ret;
 }
 
 static int exclude_super_stripes(struct btrfs_block_group *cache)