* [PATCH] Btrfs: make sure fs_info is not null before its field is used in __btrfs_panic
@ 2012-12-07 15:42 Wang Sheng-Hui
2012-12-08 10:10 ` Li Zefan
0 siblings, 1 reply; 3+ messages in thread
From: Wang Sheng-Hui @ 2012-12-07 15:42 UTC (permalink / raw)
To: chris.mason, linux-btrfs
We should make sure fs_info is not null before we refer to its field.
Add simple check here.
Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
---
fs/btrfs/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 915ac14..c6a3633 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -280,7 +280,7 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
vaf.va = &args;
errstr = btrfs_decode_error(fs_info, errno, nbuf);
- if (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)
+ if (fs_info && (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR))
panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n",
s_id, function, line, &vaf, errstr);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: make sure fs_info is not null before its field is used in __btrfs_panic
2012-12-07 15:42 [PATCH] Btrfs: make sure fs_info is not null before its field is used in __btrfs_panic Wang Sheng-Hui
@ 2012-12-08 10:10 ` Li Zefan
2012-12-08 15:08 ` Wang Sheng-Hui
0 siblings, 1 reply; 3+ messages in thread
From: Li Zefan @ 2012-12-08 10:10 UTC (permalink / raw)
To: Wang Sheng-Hui; +Cc: chris.mason, linux-btrfs
On 2012/12/7 23:42, Wang Sheng-Hui wrote:
> We should make sure fs_info is not null before we refer to its field.
> Add simple check here.
Why? Is there any caller passing NULL @fs_info to this function?
>
> Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
> ---
> fs/btrfs/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 915ac14..c6a3633 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -280,7 +280,7 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
> vaf.va = &args;
>
> errstr = btrfs_decode_error(fs_info, errno, nbuf);
> - if (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)
> + if (fs_info && (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR))
> panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n",
> s_id, function, line, &vaf, errstr);
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: make sure fs_info is not null before its field is used in __btrfs_panic
2012-12-08 10:10 ` Li Zefan
@ 2012-12-08 15:08 ` Wang Sheng-Hui
0 siblings, 0 replies; 3+ messages in thread
From: Wang Sheng-Hui @ 2012-12-08 15:08 UTC (permalink / raw)
To: Li Zefan; +Cc: chris.mason, linux-btrfs
On 2012年12月08日 18:10, Li Zefan wrote:
> On 2012/12/7 23:42, Wang Sheng-Hui wrote:
>> We should make sure fs_info is not null before we refer to its field.
>> Add simple check here.
> Why? Is there any caller passing NULL @fs_info to this function?
At least for code clean now.
In __btrfs_panic, we have:
276 if (fs_info)
277 s_id = fs_info->sb->s_id;
So for the ->mount_opt field access, we'd better do the check first.
>> Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
>> ---
>> fs/btrfs/super.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>> index 915ac14..c6a3633 100644
>> --- a/fs/btrfs/super.c
>> +++ b/fs/btrfs/super.c
>> @@ -280,7 +280,7 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
>> vaf.va = &args;
>>
>> errstr = btrfs_decode_error(fs_info, errno, nbuf);
>> - if (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)
>> + if (fs_info && (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR))
>> panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n",
>> s_id, function, line, &vaf, errstr);
>>
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-08 15:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07 15:42 [PATCH] Btrfs: make sure fs_info is not null before its field is used in __btrfs_panic Wang Sheng-Hui
2012-12-08 10:10 ` Li Zefan
2012-12-08 15:08 ` Wang Sheng-Hui
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).