* [PATCH][V2] net/ethoc: fix null dereference on error exit path
@ 2016-06-01 13:16 Colin King
2016-06-01 21:25 ` Max Filippov
2016-06-02 5:02 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-06-01 13:16 UTC (permalink / raw)
To: David S . Miller, Andrew Lunn, Florian Fainelli, Tobias Klauser,
Max Filippov, netdev
Cc: linux-kernel
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][V2] net/ethoc: fix null dereference on error exit path
2016-06-01 13:16 [PATCH][V2] net/ethoc: fix null dereference on error exit path Colin King
@ 2016-06-01 21:25 ` Max Filippov
2016-06-02 5:02 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Max Filippov @ 2016-06-01 21:25 UTC (permalink / raw)
To: Colin King
Cc: David S . Miller, Andrew Lunn, Florian Fainelli, Tobias Klauser,
netdev, linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][V2] net/ethoc: fix null dereference on error exit path
2016-06-01 13:16 [PATCH][V2] net/ethoc: fix null dereference on error exit path Colin King
2016-06-01 21:25 ` Max Filippov
@ 2016-06-02 5:02 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-06-02 5:02 UTC (permalink / raw)
To: colin.king; +Cc: andrew, f.fainelli, tklauser, jcmvbkbc, netdev, linux-kernel
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-02 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 13:16 [PATCH][V2] net/ethoc: fix null dereference on error exit path Colin King
2016-06-01 21:25 ` Max Filippov
2016-06-02 5:02 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.