Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1411196 > unrolled thread

[PATCH][V2] net/ethoc: fix null dereference on error exit path

Started byColin King <colin.king@canonical.com>
First post2016-06-01 15:20 +0200
Last post2016-06-02 07:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH][V2] net/ethoc: fix null dereference on error exit path Colin King <colin.king@canonical.com> - 2016-06-01 15:20 +0200
    Re: [PATCH][V2] net/ethoc: fix null dereference on error exit path Max Filippov <jcmvbkbc@gmail.com> - 2016-06-01 23:30 +0200
    Re: [PATCH][V2] net/ethoc: fix null dereference on error exit path David Miller <davem@davemloft.net> - 2016-06-02 07:10 +0200

#1411196 — [PATCH][V2] net/ethoc: fix null dereference on error exit path

FromColin King <colin.king@canonical.com>
Date2016-06-01 15:20 +0200
Subject[PATCH][V2] net/ethoc: fix null dereference on error exit path
Message-ID<rFedX-qG-15@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

priv is assigned to NULL however some of the early error exit paths to
label 'free' dereference priv, causing a null pointer dereference.

Move the label 'free' to just the free_netdev statement, and add a new
exit path 'free2' for the error cases were clk_disable_unprepare needs
calling before the final free.

Fixes issue found by CoverityScan, CID#113260

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/ethoc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 41b0106..4edb98c 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1195,7 +1195,7 @@ static int ethoc_probe(struct platform_device *pdev)
 	priv->mdio = mdiobus_alloc();
 	if (!priv->mdio) {
 		ret = -ENOMEM;
-		goto free;
+		goto free2;
 	}
 
 	priv->mdio->name = "ethoc-mdio";
@@ -1208,7 +1208,7 @@ static int ethoc_probe(struct platform_device *pdev)
 	ret = mdiobus_register(priv->mdio);
 	if (ret) {
 		dev_err(&netdev->dev, "failed to register MDIO bus\n");
-		goto free;
+		goto free2;
 	}
 
 	ret = ethoc_mdio_probe(netdev);
@@ -1241,9 +1241,10 @@ error2:
 error:
 	mdiobus_unregister(priv->mdio);
 	mdiobus_free(priv->mdio);
-free:
+free2:
 	if (priv->clk)
 		clk_disable_unprepare(priv->clk);
+free:
 	free_netdev(netdev);
 out:
 	return ret;
-- 
2.8.1

[toc] | [next] | [standalone]


#1411548

FromMax Filippov <jcmvbkbc@gmail.com>
Date2016-06-01 23:30 +0200
Message-ID<rFlSa-5vL-31@gated-at.bofh.it>
In reply to#1411196
On Wed, Jun 01, 2016 at 02:16:50PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> priv is assigned to NULL however some of the early error exit paths to
> label 'free' dereference priv, causing a null pointer dereference.
> 
> Move the label 'free' to just the free_netdev statement, and add a new
> exit path 'free2' for the error cases were clk_disable_unprepare needs
> calling before the final free.
> 
> Fixes issue found by CoverityScan, CID#113260
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/ethernet/ethoc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

[toc] | [prev] | [next] | [standalone]


#1411838

FromDavid Miller <davem@davemloft.net>
Date2016-06-02 07:10 +0200
Message-ID<rFt3k-1Gn-23@gated-at.bofh.it>
In reply to#1411196
From: Colin King <colin.king@canonical.com>
Date: Wed,  1 Jun 2016 14:16:50 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> priv is assigned to NULL however some of the early error exit paths to
> label 'free' dereference priv, causing a null pointer dereference.
> 
> Move the label 'free' to just the free_netdev statement, and add a new
> exit path 'free2' for the error cases were clk_disable_unprepare needs
> calling before the final free.
> 
> Fixes issue found by CoverityScan, CID#113260
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web