Patchwork [for,2.6.27?,10/10] gianfar: free/iounmap memory after an error in mii bus initialization

login
register
mail settings
Submitter Andrew Morton
Date Sept. 22, 2008, 9:10 p.m.
Message ID <200809222110.m8MLAPWg029903@imap1.linux-foundation.org>
Download mbox | patch
Permalink /patch/946/
State Accepted
Delegated to: Jeff Garzik
Headers show

Comments

Andrew Morton - Sept. 22, 2008, 9:10 p.m.
From: Andy Fleming <afleming@freescale.com>

Recent changes to MII bus initialization code added exit points which
didn't free or iounmap the bus before returning.

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=11372.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Reported-by: Daniel Marjamki <danielm77@spray.se>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/net/gianfar_mii.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
Jeff Garzik - Sept. 25, 2008, 12:49 a.m.
akpm@linux-foundation.org wrote:
> From: Andy Fleming <afleming@freescale.com>
> 
> Recent changes to MII bus initialization code added exit points which
> didn't free or iounmap the bus before returning.
> 
> Addresses http://bugzilla.kernel.org/show_bug.cgi?id=11372.
> 
> Signed-off-by: Andy Fleming <afleming@freescale.com>
> Reported-by: Daniel Marjamki <danielm77@spray.se>
> Cc: Jeff Garzik <jeff@garzik.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  drivers/net/gianfar_mii.c |   14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff -puN drivers/net/gianfar_mii.c~gianfar-free-iounmap-memory-after-an-error-in-mii-bus-initialization drivers/net/gianfar_mii.c
> --- a/drivers/net/gianfar_mii.c~gianfar-free-iounmap-memory-after-an-error-in-mii-bus-initialization
> +++ a/drivers/net/gianfar_mii.c
> @@ -211,19 +211,21 @@ static int gfar_mdio_probe(struct device
>  	gfar_write(&enet_regs->tbipa, 0);
>  	for (i = PHY_MAX_ADDR; i > 0; i--) {
>  		u32 phy_id;
> -		int r;
>  
> -		r = get_phy_id(new_bus, i, &phy_id);
> -		if (r)
> -			return r;
> +		err = get_phy_id(new_bus, i, &phy_id);
> +		if (err)
> +			goto bus_register_fail;
>  
>  		if (phy_id == 0xffffffff)
>  			break;
>  	}
>  
>  	/* The bus is full.  We don't support using 31 PHYs, sorry */
> -	if (i == 0)
> -		return -EBUSY;
> +	if (i == 0) {
> +		err = -EBUSY;
> +
> +		goto bus_register_fail;
> +	}
>  
>  	gfar_write(&enet_regs->tbipa, i);

applied


--
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

Patch

diff -puN drivers/net/gianfar_mii.c~gianfar-free-iounmap-memory-after-an-error-in-mii-bus-initialization drivers/net/gianfar_mii.c
--- a/drivers/net/gianfar_mii.c~gianfar-free-iounmap-memory-after-an-error-in-mii-bus-initialization
+++ a/drivers/net/gianfar_mii.c
@@ -211,19 +211,21 @@  static int gfar_mdio_probe(struct device
 	gfar_write(&enet_regs->tbipa, 0);
 	for (i = PHY_MAX_ADDR; i > 0; i--) {
 		u32 phy_id;
-		int r;
 
-		r = get_phy_id(new_bus, i, &phy_id);
-		if (r)
-			return r;
+		err = get_phy_id(new_bus, i, &phy_id);
+		if (err)
+			goto bus_register_fail;
 
 		if (phy_id == 0xffffffff)
 			break;
 	}
 
 	/* The bus is full.  We don't support using 31 PHYs, sorry */
-	if (i == 0)
-		return -EBUSY;
+	if (i == 0) {
+		err = -EBUSY;
+
+		goto bus_register_fail;
+	}
 
 	gfar_write(&enet_regs->tbipa, i);