* [PATCH][ext4-next] ext4: fix null pointer dereference on sbi
@ 2017-09-05 16:51 Colin King
2017-09-05 17:07 ` Dan Williams
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-09-05 16:51 UTC (permalink / raw)
To: Theodore Ts'o, Andreas Dilger, linux-ext4
Cc: kernel-janitors, linux-kernel, Dan Williams
From: Colin Ian King <colin.king@canonical.com>
In the case of a kzalloc failure when allocating sbi we end up
with a null pointer dereference on sbi when assigning sbi->s_daxdev.
Fix this by moving the assignment of sbi->s_daxdev to after the
null pointer check of sbi.
Detected by CoverityScan CID#1455379 ("Dereference before null check")
Fixes: 5e405595e5bf ("ext4: perform dax_device lookup at mount")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
fs/ext4/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 0e63fcd12c5b..71b9a667e1bc 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3422,10 +3422,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
ext4_group_t first_not_zeroed;
- sbi->s_daxdev = dax_dev;
if ((data && !orig_data) || !sbi)
goto out_free_base;
+ sbi->s_daxdev = dax_dev;
sbi->s_blockgroup_lock =
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
if (!sbi->s_blockgroup_lock)
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH][ext4-next] ext4: fix null pointer dereference on sbi
2017-09-05 16:51 [PATCH][ext4-next] ext4: fix null pointer dereference on sbi Colin King
@ 2017-09-05 17:07 ` Dan Williams
0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2017-09-05 17:07 UTC (permalink / raw)
To: Colin King
Cc: Theodore Ts'o, Andreas Dilger, linux-ext4, kernel-janitors,
linux-kernel@vger.kernel.org
On Tue, Sep 5, 2017 at 9:51 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the case of a kzalloc failure when allocating sbi we end up
> with a null pointer dereference on sbi when assigning sbi->s_daxdev.
> Fix this by moving the assignment of sbi->s_daxdev to after the
> null pointer check of sbi.
>
> Detected by CoverityScan CID#1455379 ("Dereference before null check")
>
> Fixes: 5e405595e5bf ("ext4: perform dax_device lookup at mount")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> fs/ext4/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 0e63fcd12c5b..71b9a667e1bc 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -3422,10 +3422,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
> unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
> ext4_group_t first_not_zeroed;
>
> - sbi->s_daxdev = dax_dev;
> if ((data && !orig_data) || !sbi)
> goto out_free_base;
>
> + sbi->s_daxdev = dax_dev;
> sbi->s_blockgroup_lock =
> kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
> if (!sbi->s_blockgroup_lock)
Thanks, this looks obviously correct to me. I'll append to the branch
with 5e405595e5bf.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-05 17:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-05 16:51 [PATCH][ext4-next] ext4: fix null pointer dereference on sbi Colin King
2017-09-05 17:07 ` Dan Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox