Subject: Re: [PATCH 1/2] drivers/net/ethernet/nxp/lpc_eth.c: Call mdiobus_unregister before mdiobus_free

From: Roland Stigge <[email-masked]>
Date: Sun, 28 Oct 2012 18:44:55 +0100

On 28/10/12 17:12, Peter Senna Tschudin wrote:
> Based on commit b27393aecf66199f5ddad37c302d3e0cfadbe6c0
> 
> Calling mdiobus_free without calling mdiobus_unregister causes
> BUG_ON(). This patch fixes the issue.
> 
> The semantic patch that found this issue(http://coccinelle.lip6.fr/):
> // <smpl>
> @@
> expression E;
> @@
>   ... when != mdiobus_unregister(E);
> 
> + mdiobus_unregister(E);
>   mdiobus_free(E);
> // </smpl>
> 
> Signed-off-by: Peter Senna Tschudin <[email-masked]>

Tested-by: Roland Stigge <[email-masked]>

Thanks for the patch!

Roland

> ---
> This problem is somewhat mystifying. If the patch is correct, there were
> probably many OOPSese caused by not calling mdiobus_unregister...
> Reporting anyway...
> 
>  drivers/net/ethernet/nxp/lpc_eth.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
> index 53743f7..af8b414 100644
> --- a/drivers/net/ethernet/nxp/lpc_eth.c
> +++ b/drivers/net/ethernet/nxp/lpc_eth.c
> @@ -1524,6 +1524,7 @@ static int lpc_eth_drv_remove(struct platform_device *pdev)
>  				  pldat->dma_buff_base_p);
>  	free_irq(ndev->irq, ndev);
>  	iounmap(pldat->net_base);
> +	mdiobus_unregister(pldat->mii_bus);
>  	mdiobus_free(pldat->mii_bus);
>  	clk_disable(pldat->clk);
>  	clk_put(pldat->clk);