RE: [PATCH] EDAC/ie31200: Fix error handling in ie31200_register_mci

Zhuo, Qiuxu posted 1 patch 1 month, 2 weeks ago
RE: [PATCH] EDAC/ie31200: Fix error handling in ie31200_register_mci
Posted by Zhuo, Qiuxu 1 month, 2 weeks ago
> [...]
> > --- a/drivers/edac/ie31200_edac.c
> > +++ b/drivers/edac/ie31200_edac.c
> > @@ -528,6 +528,8 @@ static int ie31200_register_mci(struct pci_dev
> > *pdev, struct res_config *cfg, in
> >  fail_unmap:
> >  	iounmap(window);
> >  fail_free:
> > +	if (mc > 0)
> 
> Since both primary and secondary memory controllers invoke
> device_initialize(), please remove this "if (mc > 0)" check to call put_device()
> unconditionally here.
> 
> > +		put_device(&priv->dev);
> >  	edac_mc_free(mci);
> >  	return ret;
> >  }
> 

On the normal driver unloading path, a corresponding put_device() is also needed.
Please include the following diff in your v2.

diff --git a/drivers/edac/ie31200_edac.c b/drivers/edac/ie31200_edac.c
index 0aea6d59f31e..4c43d7dbe047 100644
--- a/drivers/edac/ie31200_edac.c
+++ b/drivers/edac/ie31200_edac.c
@@ -603,6 +603,7 @@ static void ie31200_unregister_mcis(void)
                mci = priv->mci;
                edac_mc_del_mc(mci->pdev);
                iounmap(priv->window);
+               put_device(&priv->dev);
                edac_mc_free(mci);
        }
 } 

Thanks!
-Qiuxu