Re: [PATCH] btrfs: Fix a memory allocation failure test

From: Nikolay Borisov
Date: Sun Oct 30 2022 - 14:32:18 EST




On 30.10.22 г. 9:35 ч., Christophe JAILLET wrote:
'dip' is tested instead of 'dip->csums'.
Fix it.

Fixes: 642c5d34da53 ("btrfs: allocate the btrfs_dio_private as part of the iomap dio bio")
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>


Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>

---
fs/btrfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 966cc050cdbb..3bbd2dc6282f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8078,7 +8078,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);