Skip to content

Commit 08ca690

Browse files
BoardzMasterdavejiang
authored andcommitted
nvdimm: Fix dereference after free in register_nvdimm_pmu()
'nd_pmu->pmu.attr_groups' is dereferenced in function 'nvdimm_pmu_free_hotplug_memory' call after it has been freed. Because in function 'nvdimm_pmu_free_hotplug_memory' memory pointed by the fields of 'nd_pmu->pmu.attr_groups' is deallocated it is necessary to call 'kfree' after 'nvdimm_pmu_free_hotplug_memory'. Fixes: 0fab1ba ("drivers/nvdimm: Add perf interface to expose nvdimm performance stats") Co-developed-by: Ivanov Mikhail <[email protected]> Signed-off-by: Konstantin Meskhidze <[email protected]> Reviewed-by: Jeff Moyer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent 85ae42c commit 08ca690

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvdimm/nd_perf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ int register_nvdimm_pmu(struct nvdimm_pmu *nd_pmu, struct platform_device *pdev)
308308

309309
rc = perf_pmu_register(&nd_pmu->pmu, nd_pmu->pmu.name, -1);
310310
if (rc) {
311-
kfree(nd_pmu->pmu.attr_groups);
312311
nvdimm_pmu_free_hotplug_memory(nd_pmu);
312+
kfree(nd_pmu->pmu.attr_groups);
313313
return rc;
314314
}
315315

0 commit comments

Comments
 (0)