[PATCH 13/14] clk: avoid possible NULL ptr deref

Lucas Stach dev at lynxeye.de
Fri Feb 7 03:48:55 EST 2014


Signed-off-by: Lucas Stach <dev at lynxeye.de>
---
 drivers/clk/clkdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 66cd832..d9a1c21 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -179,9 +179,11 @@ struct clk *clk_get(struct device_d *dev, const char *con_id)
 	if (!IS_ERR(clk))
 		return clk;
 
-	clk = of_clk_get_by_name(dev->device_node, con_id);
-		if (!IS_ERR(clk))
-			return clk;
+	if (dev) {
+		clk = of_clk_get_by_name(dev->device_node, con_id);
+			if (!IS_ERR(clk))
+				return clk;
+	}
 
 	return clk_get_sys(dev_id, con_id);
 }
-- 
1.8.5.3




More information about the barebox mailing list