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


Groups > linux.kernel > #1405033

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

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] net/ethoc: fix null dereference on error exit path
Date 2016-05-22 21:10 +0200
Message-ID <rBGVc-4wz-15@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Colin Ian King <colin.king@canonical.com>

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

Examination of the code shows that all error exits via the 'free'
label path occur before priv is assigned to netdev_priv(netdev), hence
there is no need to call clk_disable_unprepare and so the location of
the label should be moved to free_netdev statement to avoid this null
dereference on priv.

Fixes issue found by CoverityScan, CID#113260

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

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 41b0106..96403a4 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1241,9 +1241,10 @@ error2:
 error:
 	mdiobus_unregister(priv->mdio);
 	mdiobus_free(priv->mdio);
-free:
+
 	if (priv->clk)
 		clk_disable_unprepare(priv->clk);
+free:
 	free_netdev(netdev);
 out:
 	return ret;
-- 
2.8.1

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] net/ethoc: fix null dereference on error exit path Colin King <colin.king@canonical.com> - 2016-05-22 21:10 +0200
  Re: [PATCH] net/ethoc: fix null dereference on error exit path Max Filippov <jcmvbkbc@gmail.com> - 2016-05-22 21:50 +0200
    Re: [PATCH] net/ethoc: fix null dereference on error exit path Colin Ian King <colin.king@canonical.com> - 2016-05-22 23:30 +0200

csiph-web