Re: [PATCH v2 1/1] EDAC/ghes: Fix for NULL pointer dereference in ghes_edac_register()

From: Borislav Petkov
Date: Thu Aug 27 2020 - 12:19:54 EST


On Thu, Aug 27, 2020 at 03:04:50PM +0100, Shiju Jose wrote:
> After the 'commit b9cae27728d1 ("EDAC/ghes: Scan the system once on driver init")'
> applied, following error has occurred in the ghes_edac_register() when
> CONFIG_DEBUG_TEST_DRIVER_REMOVE is enabled. The null ghes_hw.dimms pointer
> in the mci_for_each_dimm() of ghes_edac_register() caused the error.
>
> The error occurs when all the previously initialized ghes instances are
> removed and then probe a new ghes instance. In this case, the ghes_refcount
> would be 0, ghes_hw.dimms and mci already freed. The ghes_hw.dimms would
> be null because ghes_scan_system() would not call enumerate_dimms() again.
>
> Suggested-by: Borislav Petkov <bp@xxxxxxx>
> Signed-off-by: Shiju Jose <shiju.jose@xxxxxxxxxx>
> ---
> drivers/edac/ghes_edac.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)

Thanks, queued in edac-urgent.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette