]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2022 17:17:31 +0000 (18:17 +0100)
commit 063b1f21cc9be07291a1f5e227436f353c6d1695 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/inode.c

index 099c155ccacf45f1da5e9ab21633d376906b8f6e..893693112fb805418ccabdf666ed1dab64dd88d2 100644 (file)
@@ -8142,7 +8142,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);