Skip to content

Commit fefaae9

Browse files
orange-kaoaegl
authored andcommitted
EDAC/igen6: Avoid segmentation fault on module unload
The segmentation fault happens because: During modprobe: 1. In igen6_probe(), igen6_pvt will be allocated with kzalloc() 2. In igen6_register_mci(), mci->pvt_info will point to &igen6_pvt->imc[mc] During rmmod: 1. In mci_release() in edac_mc.c, it will kfree(mci->pvt_info) 2. In igen6_remove(), it will kfree(igen6_pvt); Fix this issue by setting mci->pvt_info to NULL to avoid the double kfree. Fixes: 10590a9 ("EDAC/igen6: Add EDAC driver for Intel client SoCs using IBECC") Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219360 Signed-off-by: Orange Kao <[email protected]> Signed-off-by: Tony Luck <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f12c946 commit fefaae9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/edac/igen6_edac.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ static int igen6_register_mci(int mc, u64 mchbar, struct pci_dev *pdev)
12451245
imc->mci = mci;
12461246
return 0;
12471247
fail3:
1248+
mci->pvt_info = NULL;
12481249
kfree(mci->ctl_name);
12491250
fail2:
12501251
edac_mc_free(mci);
@@ -1269,6 +1270,7 @@ static void igen6_unregister_mcis(void)
12691270

12701271
edac_mc_del_mc(mci->pdev);
12711272
kfree(mci->ctl_name);
1273+
mci->pvt_info = NULL;
12721274
edac_mc_free(mci);
12731275
iounmap(imc->window);
12741276
}

0 commit comments

Comments
 (0)