From: Defang Bo <bodefang@126.com>
To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Defang Bo <bodefang@126.com>
Subject: [PATCH 3/3] fs/btrfs: avoid null pointer dereference if reloc control has not been initialized
Date: Sun, 27 Dec 2020 22:55:31 +0800 [thread overview]
Message-ID: <1609080931-4048864-1-git-send-email-bodefang@126.com> (raw)
Similar to commmit<389305b2>, it turns out that fs_info::reloc_ctl can be NULL ,
so there should be a check for rc to prevent null pointer dereference.
Signed-off-by: Defang Bo <bodefang@126.com>
---
fs/btrfs/relocation.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 3602806..ca03571 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -626,6 +626,9 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
struct mapping_node *node;
struct reloc_control *rc = fs_info->reloc_ctl;
+ if (!rc)
+ return 0;
+
node = kmalloc(sizeof(*node), GFP_NOFS);
if (!node)
return -ENOMEM;
@@ -703,6 +706,9 @@ static int __update_reloc_root(struct btrfs_root *root)
struct rb_node *rb_node;
struct mapping_node *node = NULL;
struct reloc_control *rc = fs_info->reloc_ctl;
+
+ if (!rc)
+ return 0;
spin_lock(&rc->reloc_root_tree.lock);
rb_node = rb_simple_search(&rc->reloc_root_tree.rb_root,
--
2.7.4
next reply other threads:[~2020-12-27 23:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-27 14:55 Defang Bo [this message]
2021-01-04 15:11 ` [PATCH 3/3] fs/btrfs: avoid null pointer dereference if reloc control has not been initialized David Sterba
[not found] ` <125f3257.193a.176d084a633.Coremail.bodefang@126.com>
2021-01-05 11:38 ` [PATCH v2] " David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1609080931-4048864-1-git-send-email-bodefang@126.com \
--to=bodefang@126.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox