[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200921191243.27833-1-a.dewar@sussex.ac.uk>
Date: Mon, 21 Sep 2020 20:12:44 +0100
From: Alex Dewar <alex.dewar90@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Alex Dewar <a.dewar@...sex.ac.uk>, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] btrfs: Fix potential null pointer deref
In btrfs_destroy_inode(), the variable root may be NULL, but the check
for this takes place after its value has already been dereferenced to
access its fs_info member. Move the dereference operation to later in
the function.
Fixes: a6dbd429d8dd ("Btrfs: fix panic when trying to destroy a newly allocated")
Addresses-Coverity: CID 1497103: Null pointer dereferences (REVERSE_INULL)
Signed-off-by: Alex Dewar <a.dewar@...sex.ac.uk>
---
fs/btrfs/inode.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a5dae53c1e27..8f230b7bfe65 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8648,7 +8648,6 @@ void btrfs_destroy_inode(struct inode *vfs_inode)
struct btrfs_ordered_extent *ordered;
struct btrfs_inode *inode = BTRFS_I(vfs_inode);
struct btrfs_root *root = inode->root;
- struct btrfs_fs_info *fs_info = root->fs_info;
WARN_ON(!hlist_empty(&vfs_inode->i_dentry));
WARN_ON(vfs_inode->i_data.nrpages);
@@ -8673,7 +8672,7 @@ void btrfs_destroy_inode(struct inode *vfs_inode)
if (!ordered)
break;
else {
- btrfs_err(fs_info,
+ btrfs_err(root->fs_info,
"found ordered extent %llu %llu on inode cleanup",
ordered->file_offset, ordered->num_bytes);
btrfs_remove_ordered_extent(inode, ordered);
--
2.28.0
Powered by blists - more mailing lists