Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC, amd64: Add x86cpuid sanity check during init

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 <Yazen.Ghannam@amd.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/1485537863-2707-9-git-send-email-Yazen.Ghannam@amd.com
[ Get rid of err_ret label, make it a bit more readable this way. ]
Signed-off-by: Borislav Petkov <bp@suse.de>

authored by

Yazen Ghannam and committed by
Borislav Petkov
1bd9900b 4688c9b4

+5 -2
+4 -2
drivers/edac/amd64_edac.c
··· 3440 3440 int err = -ENODEV; 3441 3441 int i; 3442 3442 3443 + if (!x86_match_cpu(amd64_cpuids)) 3444 + return -ENODEV; 3445 + 3443 3446 if (amd_cache_northbridges() < 0) 3444 - goto err_ret; 3447 + return -ENODEV; 3445 3448 3446 3449 opstate_init(); 3447 3450 ··· 3500 3497 kfree(ecc_stngs); 3501 3498 ecc_stngs = NULL; 3502 3499 3503 - err_ret: 3504 3500 return err; 3505 3501 } 3506 3502
+1
drivers/edac/amd64_edac.h
··· 16 16 #include <linux/slab.h> 17 17 #include <linux/mmzone.h> 18 18 #include <linux/edac.h> 19 + #include <asm/cpu_device_id.h> 19 20 #include <asm/msr.h> 20 21 #include "edac_module.h" 21 22 #include "mce_amd.h"