Skip to content

Commit

Permalink
EDAC, amd64: Add x86cpuid sanity check during init
Browse files Browse the repository at this point in the history
Match one of the devices in amd64_cpuids[] before loading the module.
This is an additional sanity check against users trying to load
amd64_edac_mod on unsupported systems.

Signed-off-by: Yazen Ghannam <[email protected]>
Cc: linux-edac <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ Get rid of err_ret label, make it a bit more readable this way. ]
Signed-off-by: Borislav Petkov <[email protected]>
  • Loading branch information
yghannam authored and suryasaimadhu committed Jan 28, 2017
1 parent 4688c9b commit 1bd9900
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/edac/amd64_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -3440,8 +3440,11 @@ static int __init amd64_edac_init(void)
int err = -ENODEV;
int i;

if (!x86_match_cpu(amd64_cpuids))
return -ENODEV;

if (amd_cache_northbridges() < 0)
goto err_ret;
return -ENODEV;

opstate_init();

Expand Down Expand Up @@ -3497,7 +3500,6 @@ static int __init amd64_edac_init(void)
kfree(ecc_stngs);
ecc_stngs = NULL;

err_ret:
return err;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/edac/amd64_edac.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/mmzone.h>
#include <linux/edac.h>
#include <asm/cpu_device_id.h>
#include <asm/msr.h>
#include "edac_module.h"
#include "mce_amd.h"
Expand Down

0 comments on commit 1bd9900

Please sign in to comment.