]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: fix a memory allocation failure test in btrfs_submit_direct
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 30 Oct 2022 07:35:28 +0000 (08:35 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 31 Oct 2022 15:50:15 +0000 (16:50 +0100)
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 <nborisov@suse.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 45ebef8d3ea8dd95cd06b967017e3751a64550be..f0ebc17aeb6720d622c5996dcbe449f3ef5bef7b 100644 (file)
@@ -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);