* [PATCH] btrfs: Fix potential null pointer deref
@ 2020-09-21 19:12 Alex Dewar
2020-09-21 19:16 ` Josef Bacik
2020-09-24 14:11 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Alex Dewar @ 2020-09-21 19:12 UTC (permalink / raw)
Cc: Alex Dewar, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
linux-kernel
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@sussex.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Fix potential null pointer deref
2020-09-21 19:12 [PATCH] btrfs: Fix potential null pointer deref Alex Dewar
@ 2020-09-21 19:16 ` Josef Bacik
2020-09-24 14:11 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2020-09-21 19:16 UTC (permalink / raw)
To: Alex Dewar
Cc: Alex Dewar, Chris Mason, David Sterba, linux-btrfs, linux-kernel
On 9/21/20 3:12 PM, Alex Dewar wrote:
> 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@sussex.ac.uk>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Fix potential null pointer deref
2020-09-21 19:12 [PATCH] btrfs: Fix potential null pointer deref Alex Dewar
2020-09-21 19:16 ` Josef Bacik
@ 2020-09-24 14:11 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-09-24 14:11 UTC (permalink / raw)
To: linux-btrfs; +Cc: Chris Mason, Josef Bacik, David Sterba, linux-kernel
On Mon, Sep 21, 2020 at 08:12:44PM +0100, Alex Dewar wrote:
> 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@sussex.ac.uk>
For some reason my replies did not get to linux-btrfs@, so for the
record the changes has been folded to the patch "btrfs: clean BTRFS_I
usage in btrfs_destroy_inode".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-24 14:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 19:12 [PATCH] btrfs: Fix potential null pointer deref Alex Dewar
2020-09-21 19:16 ` Josef Bacik
2020-09-24 14:11 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).