From: Christophe JAILLET Date: Sun, 30 Oct 2022 07:35:28 +0000 (+0100) Subject: btrfs: fix a memory allocation failure test in btrfs_submit_direct X-Git-Tag: v6.1-rc4~24^2~7 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=063b1f21cc9be07291a1f5e227436f353c6d1695;p=users%2Fdwmw2%2Flinux.git btrfs: fix a memory allocation failure test in btrfs_submit_direct After allocation 'dip' is tested instead of 'dip->csums'. Fix it. Fixes: 642c5d34da53 ("btrfs: allocate the btrfs_dio_private as part of the iomap dio bio") CC: stable@vger.kernel.org # 5.19+ Reviewed-by: Nikolay Borisov Signed-off-by: Christophe JAILLET Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 45ebef8d3ea8d..f0ebc17aeb672 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7980,7 +7980,7 @@ static void btrfs_submit_direct(const struct iomap_iter *iter, */ status = BLK_STS_RESOURCE; dip->csums = kcalloc(nr_sectors, fs_info->csum_size, GFP_NOFS); - if (!dip) + if (!dip->csums) goto out_err; status = btrfs_lookup_bio_sums(inode, dio_bio, dip->csums);