From a66bdf5d11b0ba8e473ef90ba7e0e6399b5fc825 Mon Sep 17 00:00:00 2001 From: Sughosh Ganu Date: Thu, 26 Apr 2018 15:46:49 +0530 Subject: [PATCH] EDAC, ghes: Add a null pointer check in ghes_edac_unregister() Add a null check for ghes_pvt, before dereferencing it. The pointer could still be null in case the return path is taken before initialising ghes_pvt in the registration function. Reviewed-by: Toshi Kani Signed-off-by: Sughosh Ganu Cc: Mauro Carvalho Chehab Cc: linux-edac Cc: lkml Link: http://lkml.kernel.org/r/1524737809-24475-1-git-send-email-sughosh.ganu@arm.com Signed-off-by: Borislav Petkov --- drivers/edac/ghes_edac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 7fdbfe871f5c..758744038d93 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -517,6 +517,9 @@ void ghes_edac_unregister(struct ghes *ghes) { struct mem_ctl_info *mci; + if (!ghes_pvt) + return; + mci = ghes_pvt->mci; edac_mc_del_mc(mci->pdev); edac_mc_free(mci);