diff mbox

net/ethernet: ks8851_mll unregister_netdev() before freeing

Message ID 20120606063129.GA26829@elgon.mountain
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Dan Carpenter June 6, 2012, 6:31 a.m. UTC
We added another error condition here, but if we were to hit it then
we need to unregister_netdev() before doing the free_netdev().
Otherwise we would hit the BUG_ON() in free_netdev():

	BUG_ON(dev->reg_state != NETREG_UNREGISTERED);

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static checker stuff.  I don't have this hardware.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Raffaele RECALCATI June 6, 2012, 5:03 p.m. UTC | #1
On 09:31 Wed 06 Jun     , Dan Carpenter wrote:
> We added another error condition here, but if we were to hit it then
> we need to unregister_netdev() before doing the free_netdev().
> Otherwise we would hit the BUG_ON() in free_netdev():
> 
> 	BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Static checker stuff.  I don't have this hardware.
> 
> diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
> index 70bd329..875dd5e 100644
> --- a/drivers/net/ethernet/micrel/ks8851_mll.c
> +++ b/drivers/net/ethernet/micrel/ks8851_mll.c
> @@ -1606,7 +1606,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
>  	if (!pdata) {
>  		netdev_err(netdev, "No platform data\n");
>  		err = -ENODEV;
> -		goto err_register;
> +		goto err_pdata;
>  	}
>  	memcpy(ks->mac_addr, pdata->mac_addr, 6);
>  	if (!is_valid_ether_addr(ks->mac_addr)) {
> @@ -1626,6 +1626,8 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
>  		    (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
>  	return 0;
>  
> +err_pdata:
> +	unregister_netdev(netdev);
>  err_register:
>  err_get_irq:
>  	iounmap(ks->hw_addr_cmd);

Tested-by: Raffaele Recalcati <raffaele.recalcati@bticino.it>

[    2.274993] ks8851_mll ks8851_mll: (unregistered net_device): message enable is 0
[    2.282897] ks8851_mll ks8851_mll: (unregistered net_device): the selftest passes
[    2.302246] ks8851_mll ks8851_mll: eth0: No platform data

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller June 7, 2012, 8:15 p.m. UTC | #2
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 6 Jun 2012 09:31:29 +0300

> We added another error condition here, but if we were to hit it then
> we need to unregister_netdev() before doing the free_netdev().
> Otherwise we would hit the BUG_ON() in free_netdev():
> 
> 	BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, but please be explicit that your patch is against one
tree or another.  This one was for net-next only, but I tried
initially to apply it to net which failed.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Carpenter June 8, 2012, 12:53 p.m. UTC | #3
On Thu, Jun 07, 2012 at 01:15:44PM -0700, David Miller wrote:
> From: Dan Carpenter <dan.carpenter@oracle.com>
> Date: Wed, 6 Jun 2012 09:31:29 +0300
> 
> > We added another error condition here, but if we were to hit it then
> > we need to unregister_netdev() before doing the free_netdev().
> > Otherwise we would hit the BUG_ON() in free_netdev():
> > 
> > 	BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Applied, but please be explicit that your patch is against one
> tree or another.  This one was for net-next only, but I tried
> initially to apply it to net which failed.

Sorry about that.  Will be more careful in the future.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index 70bd329..875dd5e 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -1606,7 +1606,7 @@  static int __devinit ks8851_probe(struct platform_device *pdev)
 	if (!pdata) {
 		netdev_err(netdev, "No platform data\n");
 		err = -ENODEV;
-		goto err_register;
+		goto err_pdata;
 	}
 	memcpy(ks->mac_addr, pdata->mac_addr, 6);
 	if (!is_valid_ether_addr(ks->mac_addr)) {
@@ -1626,6 +1626,8 @@  static int __devinit ks8851_probe(struct platform_device *pdev)
 		    (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
 	return 0;
 
+err_pdata:
+	unregister_netdev(netdev);
 err_register:
 err_get_irq:
 	iounmap(ks->hw_addr_cmd);