Skip to contentSkip to conversation

clk: Do not dereference potential NULL pointer

PATCH New Thierry Reding 3 participants 4 messages Oct 31, 2013 – Nov 1, 2013 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: Do not dereference potential NULL pointer

A NULL pointer may be passed to _clk_register() for the dev parameter (via clk_register()). Make sure not to dereference it before checking that it's valid.

---
 drivers/clk/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk.c +1 -1
index b68a999..c0b52e3 100644
@@ -1976,7 +1976,7 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
 		hw->regmap = hw->init->regmap;
 	else if (dev && dev_get_regmap(dev, NULL))
 		hw->regmap = dev_get_regmap(dev, NULL);
-	else if (dev->parent)
+	else if (dev && dev->parent)
 		hw->regmap = dev_get_regmap(dev->parent, NULL);
 
 	/* allocate local copy in case parent_names is __initdata */
Signature · 1 line
1.8.4
#1 lore raw

PATCH 1/1 clk: Do not dereference potential NULL pointer

Quoted 6 lines · Thierry Reding

A NULL pointer may be passed to _clk_register() for the dev parameter (via clk_register()). Make sure not to dereference it before checking that it's valid.

---

Ugh I had this fixed but didn't send it.

Quoted 16 lines
 drivers/clk/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk.c +1 -1
index b68a999..c0b52e3 100644
@@ -1976,7 +1976,7 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
 		hw->regmap = hw->init->regmap;
 	else if (dev && dev_get_regmap(dev, NULL))
 		hw->regmap = dev_get_regmap(dev, NULL);
-	else if (dev->parent)
+	else if (dev && dev->parent)
 		hw->regmap = dev_get_regmap(dev->parent, NULL);
 
 	/* allocate local copy in case parent_names is __initdata */
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw

PATCH 1/1 clk: Do not dereference potential NULL pointer

In reply to Thierry Reding

Quoting Thierry Reding (2013-10-31 05:03:56)

Quoted 5 lines

A NULL pointer may be passed to _clk_register() for the dev parameter (via clk_register()). Make sure not to dereference it before checking that it's valid.

Hi Thierry,

I saw Olof's fix first so I took that and applied your Ack.

Regards,
Mike

Quoted 19 lines
---
 drivers/clk/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk.c +1 -1
index b68a999..c0b52e3 100644
@@ -1976,7 +1976,7 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
                hw->regmap = hw->init->regmap;
        else if (dev && dev_get_regmap(dev, NULL))
                hw->regmap = dev_get_regmap(dev, NULL);
-       else if (dev->parent)
+       else if (dev && dev->parent)
                hw->regmap = dev_get_regmap(dev->parent, NULL);
 
        /* allocate local copy in case parent_names is __initdata */
Signature · 1 line
1.8.4
#3 lore raw

PATCH 1/1 clk: Do not dereference potential NULL pointer

Quoted 10 lines · Mike Turquette

Quoting Thierry Reding (2013-10-31 05:03:56)

Quoted 5 lines

A NULL pointer may be passed to _clk_register() for the dev parameter (via clk_register()). Make sure not to dereference it before checking that it's valid.

Hi Thierry,

I saw Olof's fix first so I took that and applied your Ack.

Perhaps we need a new kind of tag. Something like Also-by: =)

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131101/b86181ce/attachment.sig>