[PATCH 2/3] clk: Prevent a hanging pointer being abused

From: Charles Manning
Date: Mon Jul 21 2014 - 22:21:26 EST


Clock init structs are normally created on the stack.

If the pointer is left intact after clk_register then there is
opportunity for clk drivers to dereference the pointer.

This was causing a problem in socfpga/clk.c for instance.

Better to NULL out the pointer so it can't be abused.

Signed-off-by: Charles Manning <cdhmanning@xxxxxxxxx>
---
drivers/clk/clk.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ec41922..9e92170 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1973,6 +1973,10 @@ struct clk *__clk_register(struct device *dev, struct clk_hw *hw)
clk->owner = NULL;

ret = __clk_init(dev, clk);
+
+ /* Prevent a hanging pointer being left around. */
+ hw->init = NULL;
+
if (ret)
return ERR_PTR(ret);

--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/