Skip to content

Commit

Permalink
btrfs: fix a memory allocation failure test in btrfs_submit_direct
Browse files Browse the repository at this point in the history
After allocation 'dip' is tested instead of 'dip->csums'.  Fix it.

Fixes: 642c5d3 ("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>
  • Loading branch information
tititiou36 authored and kdave committed Oct 31, 2022
1 parent 76a66ba commit 063b1f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 063b1f2

Please sign in to comment.