Skip to content

Commit cb6ae45

Browse files
committed
efivarfs: Defer PM notifier registration until .fill_super
syzbot reports an issue that turns out to be caused by the fact that the efivarfs PM notifier may be invoked before the efivarfs_fs_info::sb field is populated, resulting in a NULL deference. So defer the registration until efivarfs_fill_super() is invoked. Reported-by: syzbot+00d13e505ef530a45100@syzkaller.appspotmail.com Tested-by: syzbot+00d13e505ef530a45100@syzkaller.appspotmail.com Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent d6a2d02 commit cb6ae45

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/efivarfs/super.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
367367
if (err)
368368
return err;
369369

370+
register_pm_notifier(&sfi->pm_nb);
371+
370372
return efivar_init(efivarfs_callback, sb, true);
371373
}
372374

@@ -552,7 +554,6 @@ static int efivarfs_init_fs_context(struct fs_context *fc)
552554

553555
sfi->pm_nb.notifier_call = efivarfs_pm_notify;
554556
sfi->pm_nb.priority = 0;
555-
register_pm_notifier(&sfi->pm_nb);
556557

557558
return 0;
558559
}

0 commit comments

Comments
 (0)