Skip to content

Commit

Permalink
x86/mce/AMD: Make the init code more robust
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Boris Ostrovsky <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
KAGA-KOKO authored and torvalds committed Dec 27, 2016
1 parent b9d9d69 commit 0dad3a3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/x86/kernel/cpu/mcheck/mce_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,9 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)
const char *name = get_name(bank, NULL);
int err = 0;

if (!dev)
return -ENODEV;

if (is_shared_bank(bank)) {
nb = node_to_amd_nb(amd_get_nb_id(cpu));

Expand Down

0 comments on commit 0dad3a3

Please sign in to comment.