From 48b1ef558fc01bc0d222ff364de363d3254874b1 Mon Sep 17 00:00:00 2001 From: yuedl1 Date: Wed, 29 Jul 2020 13:36:13 +0800 Subject: [PATCH] exfat:fixed fs_error access null pointer when exfat unmounted, but fs_error maybe callbacked by block layer still.so just check whether the sb and sb_fs_info was released. Change-Id: I30f55a2f3a20cbaecccbcf12d143590a02d1bf19 Signed-off-by: yuedl1 Reviewed-on: https://gerrit.mot.com/1708296 Tested-by: Jira Key SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Reviewed-by: Zhenxin Xi Submit-Approved: Jira Key --- fs/exfat/exfat_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/exfat/exfat_core.c b/fs/exfat/exfat_core.c index 9fb6b84f2848..07befe78d03c 100644 --- a/fs/exfat/exfat_core.c +++ b/fs/exfat/exfat_core.c @@ -1753,8 +1753,14 @@ void fs_sync(struct super_block *sb, s32 do_sync) void fs_error(struct super_block *sb) { - struct exfat_mount_options *opts = &EXFAT_SB(sb)->options; - struct exfat_sb_info *sbi = EXFAT_SB(sb); + struct exfat_mount_options *opts; + struct exfat_sb_info *sbi; + if ( sb == NULL || EXFAT_SB(sb)== NULL) { + printk(KERN_ERR "[EXFAT] filesystem maybe unmounted!!!\n"); + return; + } + opts = &EXFAT_SB(sb)->options; + sbi = EXFAT_SB(sb); if (opts->errors == EXFAT_ERRORS_PANIC) panic("[EXFAT] Filesystem panic from previous error\n");