[PATCH v2 5/8] EDAC/aspeed: Free the mem_ctl_info unconditionally on remove
Ryan Chen <[email protected]>
| Newsgroups | org.kernel.vger.linux-kernel,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-edac,org.ozlabs.lists.linux-aspeed |
|---|---|
| Message-ID | <[email protected]> |
aspeed_remove() is a driver .remove callback, so it only runs for a device that has already probed successfully and registered its mem_ctl_info. In that case edac_mc_del_mc() always returns the same, valid pointer, and the NULL check on its return value can never be false. Fetch the mem_ctl_info from the platform device's driver data instead and free it unconditionally, dropping the redundant check. This also decouples the teardown from the return value of edac_mc_del_mc(). Signed-off-by: Ryan Chen <[email protected]> --- drivers/edac/aspeed_edac.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index cd2a6fcca355..352910e1defc 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -343,7 +343,7 @@ static int aspeed_probe(struct platform_device *pdev) static void aspeed_remove(struct platform_device *pdev) { - struct mem_ctl_info *mci; + struct mem_ctl_info *mci = platform_get_drvdata(pdev); int irq; /* disable interrupts */ @@ -352,12 +352,11 @@ static void aspeed_remove(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); WARN_ON(irq < 0); - devm_free_irq(&pdev->dev, irq, platform_get_drvdata(pdev)); + devm_free_irq(&pdev->dev, irq, mci); /* free resources */ - mci = edac_mc_del_mc(&pdev->dev); - if (mci) - edac_mc_free(mci); + edac_mc_del_mc(&pdev->dev); + edac_mc_free(mci); } static const struct of_device_id aspeed_of_match[] = { -- 2.34.1