Skip to content

Commit cd8100f

Browse files
committed
EDAC/ghes: Clear scanned data on unload
Commit b972fdb ("EDAC/ghes: Fix NULL pointer dereference in ghes_edac_register()") didn't clear all the information from the scanned system and, more specifically, left ghes_hw.num_dimms to its previous value. On a second load (CONFIG_DEBUG_TEST_DRIVER_REMOVE=y), the driver would use the leftover num_dimms value which is not 0 and thus the 0 check in enumerate_dimms() will get bypassed and it would go directly to the pointer deref: d = &hw->dimms[hw->num_dimms]; which is, of course, NULL: #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 0 P4D 0 Oops: 0002 [#1] PREEMPT SMP CPU: 7 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc4+ #7 Hardware name: GIGABYTE MZ01-CE1-00/MZ01-CE1-00, BIOS F02 08/29/2018 RIP: 0010:enumerate_dimms.cold+0x7b/0x375 Reset the whole ghes_hw on driver unregister so that no stale values are used on a second system scan. Fixes: b972fdb ("EDAC/ghes: Fix NULL pointer dereference in ghes_edac_register()") Cc: Shiju Jose <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 856deb8 commit cd8100f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/edac/ghes_edac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ void ghes_edac_unregister(struct ghes *ghes)
632632
mutex_lock(&ghes_reg_mutex);
633633

634634
system_scanned = false;
635+
memset(&ghes_hw, 0, sizeof(struct ghes_hw_desc));
635636

636637
if (!refcount_dec_and_test(&ghes_refcount))
637638
goto unlock;

0 commit comments

Comments
 (0)