forked from luck/tmp_suning_uos_patched
1e72e673b9
ghes_edac models a single logical memory controller, and uses a global
ghes_init variable to ensure only the first ghes_edac_register() will
do anything.
ghes_edac is registered the first time a GHES entry in the HEST is
probed. There may be multiple entries, so subsequent attempts to
register ghes_edac are silently ignored as the work has already been
done.
When a GHES entry is unregistered, it calls ghes_edac_unregister(),
which free()s the memory behind the global variables in ghes_edac.
But there may be multiple GHES entries, the next call to
ghes_edac_unregister() will dereference the free()d memory, and attempt
to free it a second time.
This may also be triggered on a platform with one GHES entry, if the
driver is unbound/re-bound and unbound. The re-bind step will do
nothing because of ghes_init, the second unbind will then do the same
work as the first.
Doing the unregister work on the first call is unsafe, as another
CPU may be processing a notification in ghes_edac_report_mem_error(),
using the memory we are about to free.
ghes_init is already half of the reference counting. We only need
to do the register work for the first call, and the unregister work
for the last. Add the unregister check.
This means we no longer free ghes_edac's memory while there are
GHES entries that may receive a notification.
This was detected by KASAN and DEBUG_TEST_DRIVER_REMOVE.
[ bp: merge into a single patch. ]
Fixes:
|
||
---|---|---|
.. | ||
altera_edac.c | ||
altera_edac.h | ||
amd64_edac_dbg.c | ||
amd64_edac_inj.c | ||
amd64_edac.c | ||
amd64_edac.h | ||
amd76x_edac.c | ||
amd8111_edac.c | ||
amd8111_edac.h | ||
amd8131_edac.c | ||
amd8131_edac.h | ||
armada_xp_edac.c | ||
aspeed_edac.c | ||
bluefield_edac.c | ||
cell_edac.c | ||
cpc925_edac.c | ||
debugfs.c | ||
e7xxx_edac.c | ||
e752x_edac.c | ||
edac_device_sysfs.c | ||
edac_device.c | ||
edac_device.h | ||
edac_mc_sysfs.c | ||
edac_mc.c | ||
edac_mc.h | ||
edac_module.c | ||
edac_module.h | ||
edac_pci_sysfs.c | ||
edac_pci.c | ||
edac_pci.h | ||
fsl_ddr_edac.c | ||
fsl_ddr_edac.h | ||
ghes_edac.c | ||
highbank_l2_edac.c | ||
highbank_mc_edac.c | ||
i7core_edac.c | ||
i10nm_base.c | ||
i3000_edac.c | ||
i3200_edac.c | ||
i5000_edac.c | ||
i5100_edac.c | ||
i5400_edac.c | ||
i7300_edac.c | ||
i82443bxgx_edac.c | ||
i82860_edac.c | ||
i82875p_edac.c | ||
i82975x_edac.c | ||
ie31200_edac.c | ||
Kconfig | ||
layerscape_edac.c | ||
Makefile | ||
mce_amd.c | ||
mce_amd.h | ||
mpc85xx_edac.c | ||
mpc85xx_edac.h | ||
mv64x60_edac.c | ||
mv64x60_edac.h | ||
octeon_edac-l2c.c | ||
octeon_edac-lmc.c | ||
octeon_edac-pc.c | ||
octeon_edac-pci.c | ||
pasemi_edac.c | ||
pnd2_edac.c | ||
pnd2_edac.h | ||
ppc4xx_edac.c | ||
ppc4xx_edac.h | ||
qcom_edac.c | ||
r82600_edac.c | ||
sb_edac.c | ||
sifive_edac.c | ||
skx_base.c | ||
skx_common.c | ||
skx_common.h | ||
synopsys_edac.c | ||
thunderx_edac.c | ||
ti_edac.c | ||
wq.c | ||
x38_edac.c | ||
xgene_edac.c |