Skip to content

Commit 0dad3a3

Browse files
KAGA-KOKOtorvalds
authored andcommitted
x86/mce/AMD: Make the init code more robust
If mce_device_init() fails then the mce device pointer is NULL and the AMD mce code happily dereferences it. Add a sanity check. Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de> Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b9d9d69 commit 0dad3a3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kernel/cpu/mcheck/mce_amd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,9 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)
11821182
const char *name = get_name(bank, NULL);
11831183
int err = 0;
11841184

1185+
if (!dev)
1186+
return -ENODEV;
1187+
11851188
if (is_shared_bank(bank)) {
11861189
nb = node_to_amd_nb(amd_get_nb_id(cpu));
11871190

0 commit comments

Comments
 (0)