@@ -40,6 +40,7 @@ struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
pci->pvt_info = kzalloc(sz_pvt, GFP_KERNEL);
if (!pci->pvt_info)
goto free;
+ pci->pvt_managed_by_edac_core = true;
}
pci->op_state = OP_ALLOC;
@@ -69,6 +69,11 @@ struct edac_pci_ctl_info {
const char *dev_name; /* pci/platform/etc... name */
void *pvt_info; /* pointer to 'private driver' info */
+ /*
+ * Indicate whether the resource pointed by pvt_info is managed by
+ * EDAC core
+ */
+ bool pvt_managed_by_edac_core;
unsigned long start_time; /* edac_pci load start time (jiffies) */
@@ -83,6 +83,8 @@ static void edac_pci_instance_release(struct kobject *kobj)
/* decrement reference count on top main kobj */
kobject_put(edac_pci_top_main_kobj);
+ if (pci->pvt_managed_by_edac_core)
+ kfree(pci->pvt_info);
kfree(pci); /* Free the control struct */
}