Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1730390 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2017-09-11 17:20 +0200 |
| Last post | 2017-09-12 13:30 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] btrfs: avoid null pointer dereference on fs_info when calling btrfs_crit Colin King <colin.king@canonical.com> - 2017-09-11 17:20 +0200
Re: [PATCH] btrfs: avoid null pointer dereference on fs_info when calling btrfs_crit David Sterba <dsterba@suse.cz> - 2017-09-12 13:30 +0200
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2017-09-11 17:20 +0200 |
| Subject | [PATCH] btrfs: avoid null pointer dereference on fs_info when calling btrfs_crit |
| Message-ID | <uoyFb-57i-17@gated-at.bofh.it> |
From: Colin Ian King <colin.king@canonical.com>
There are checks on fs_info in __btrfs_panic to avoid dereferencing a
null fs_info, however, there is a call to btrfs_crit that may also
dereference a null fs_info. Fix this by adding a check to see if fs_info
is null and only print the s_id if fs_info is non-null.
Detected by CoverityScan CID#401973 ("Dereference after null check")
Fixes: efe120a067c8 ("Btrfs: convert printk to btrfs_ and fix BTRFS prefix")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
fs/btrfs/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index e56a93f3113e..c669241f936e 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -202,7 +202,6 @@ static struct ratelimit_state printk_limits[] = {
void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
{
- struct super_block *sb = fs_info->sb;
char lvl[PRINTK_MAX_SINGLE_HEADER_LEN + 1] = "\0";
struct va_format vaf;
va_list args;
@@ -228,7 +227,8 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
vaf.va = &args;
if (__ratelimit(ratelimit))
- printk("%sBTRFS %s (device %s): %pV\n", lvl, type, sb->s_id, &vaf);
+ printk("%sBTRFS %s (device %s): %pV\n", lvl, type,
+ fs_info ? fs_info->sb->s_id : "<unknown>", &vaf);
va_end(args);
}
--
2.14.1
[toc] | [next] | [standalone]
| From | David Sterba <dsterba@suse.cz> |
|---|---|
| Date | 2017-09-12 13:30 +0200 |
| Subject | Re: [PATCH] btrfs: avoid null pointer dereference on fs_info when calling btrfs_crit |
| Message-ID | <uoRy9-Ch-5@gated-at.bofh.it> |
| In reply to | #1730390 |
On Mon, Sep 11, 2017 at 04:15:28PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> There are checks on fs_info in __btrfs_panic to avoid dereferencing a
> null fs_info, however, there is a call to btrfs_crit that may also
> dereference a null fs_info. Fix this by adding a check to see if fs_info
> is null and only print the s_id if fs_info is non-null.
>
> Detected by CoverityScan CID#401973 ("Dereference after null check")
>
> Fixes: efe120a067c8 ("Btrfs: convert printk to btrfs_ and fix BTRFS prefix")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web