Avoid a NULL pointer in btrfs
PATCH 1/1 Avoid a NULL pointer in btrfs
In Yang Ruirui's mail, the btrfs will create a oops. This is caused by a null pointer in test_range_bit() while lock the spinlock.
So, It is necessary to add a pointer check into test_range_bit()
---
---fs/btrfs/extent_io.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
fs/btrfs/extent_io.c +0 -0
@@ -1553,6 +1553,9 @@ int test_range_bit(struct extent_io_tree *tree,
u64 start, u64 end,
struct rb_node *node;
int bitset = 0;
+ if (tree == NULL)
+ return bitset;
+spin_lock(&tree->lock);
if (cached && cached->tree && cached->start == start) node = &cached->rb_node;
Signature · 7 lines
1.7.3.3 --- Best Regards, Liu Wenyi
Josef Bacik
NAKQuoted 5 lines · Liuwenyi
In Yang Ruirui's mail, the btrfs will create a oops. This is caused by a null pointer in
test_range_bit()while lock the spinlock.So, It is necessary to add a pointer check into
test_range_bit()
NAK, the tree shouldn't be null coming into this function, something else is going wrong. What oops is this? Thanks,
Josef
Excerpts from Josef Bacik's message of 2011-01-19 09:14:02 -0500:
Quoted 10 lines · Liuwenyi
Quoted 5 lines
In Yang Ruirui's mail, the btrfs will create a oops. This is caused by a null pointer in
test_range_bit()while lock the spinlock.So, It is necessary to add a pointer check into
test_range_bit()NAK, the tree shouldn't be null coming into this function, something else is going wrong. What oops is this? Thanks,
What was your metadata blocksize for this oops? This call should never happen.
I think there is a larger problem, probably in the IO error handling code since the trace had io errors beforehand.
-chris
=E4=BA=8E 2011-1-19 23:52, Chris Mason =E5=86=99=E9=81=93:
Quoted 3 lines
Excerpts from Josef Bacik's message of 2011-01-19 09:14:02 -0500:
Quoted 2 lines · Liuwenyi
Quoted 1 line
In Yang Ruirui's mail, the btrfs will create a oops. This is caused=
by a
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
null pointer in
test_range_bit()while lock the spinlock.So, It is necessary to add a pointer check into
test_range_bit()NAK, the tree shouldn't be null coming into this function, something=
else is
Quoted 1 line
Quoted 1 line
going wrong. What oops is this? Thanks,
The mail is here http://lkml.org/lkml/2011/1/19/24
another mesg is here http://www.aei.mpg.de/~crmafra/dmesg-2.6.35.3.txt
Quoted 1 line
What was your metadata blocksize for this oops? This call should nev=
er
Quoted 1 line
happen.
It is rare and hard to reproduced. So, I update this patch, just avoid = a=20
null pointer calling.
Quoted 2 lines
I think there is a larger problem, probably in the IO error handling code since the trace had io errors beforehand.
Yes, I agree. This situation is too strange to happen.
Quoted 1 line
-chris
---
Best Regards,
Liu Wenyi