diff options
| author | Pei Xiao <xiaopei01@kylinos.cn> | 2024-10-30 15:48:01 +0800 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-11-07 16:48:21 -0500 |
| commit | 93d53f1caf2cf861d0f28d096792d3b92efae178 (patch) | |
| tree | a7ec109e5876b44934aaec8f36398caa4eed8778 /fs/bcachefs/journal_io.c | |
| parent | bcachefs: Ensure BCH_FS_may_go_rw is set before exiting recovery (diff) | |
| download | linux-93d53f1caf2cf861d0f28d096792d3b92efae178.tar.gz linux-93d53f1caf2cf861d0f28d096792d3b92efae178.zip | |
bcachefs: add check NULL return of bio_kmalloc in journal_read_bucket
bio_kmalloc may return NULL, will cause NULL pointer dereference.
Add check NULL return for bio_kmalloc in journal_read_bucket.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Fixes: ac10a9611d87 ("bcachefs: Some fixes for building in userspace")
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
| -rw-r--r-- | fs/bcachefs/journal_io.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 954f6a96e0f4..ccaafa90f4f4 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1012,6 +1012,8 @@ reread: nr_bvecs = buf_pages(buf->data, sectors_read << 9); bio = bio_kmalloc(nr_bvecs, GFP_KERNEL); + if (!bio) + return -BCH_ERR_ENOMEM_journal_read_bucket; bio_init(bio, ca->disk_sb.bdev, bio->bi_inline_vecs, nr_bvecs, REQ_OP_READ); bio->bi_iter.bi_sector = offset; |
