Skip to content

Commit

Permalink
i5000-edac: hold reference to mci kobject
Browse files Browse the repository at this point in the history
It turns out that edac_mc_del_mc will kobject_put the last kref on the
mci object.

If the timing is just right, that means that the mci object is freed
before before i5000_remove_one has a chance to free the resources
associated with it, causing a null pointer exceptions when unloading the
driver.  Insert a kobject_{get,put} pair so that this doesn't happen.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Darrick J. Wong authored and Linus Torvalds committed Nov 13, 2008
1 parent fe2d5ff commit f0f7e0d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/edac/i5000_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx)
if (mci == NULL)
return -ENOMEM;

kobject_get(&mci->edac_mci_kobj);
debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci);

mci->dev = &pdev->dev; /* record ptr to the generic device */
Expand Down Expand Up @@ -1453,6 +1454,7 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx)
i5000_put_devices(mci);

fail0:
kobject_put(&mci->edac_mci_kobj);
edac_mc_free(mci);
return -ENODEV;
}
Expand Down Expand Up @@ -1498,7 +1500,7 @@ static void __devexit i5000_remove_one(struct pci_dev *pdev)

/* retrieve references to resources, and free those resources */
i5000_put_devices(mci);

kobject_put(&mci->edac_mci_kobj);
edac_mc_free(mci);
}

Expand Down

0 comments on commit f0f7e0d

Please sign in to comment.