diff options
author | James Hogan <james.hogan@imgtec.com> | 2013-08-29 07:10:51 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-08-30 15:52:01 -0400 |
commit | 903efc553f738030a4ffa23fa03e7f329655c1c2 (patch) | |
tree | 3c0b612bf3889b07fd8b571ad5e35c9659ffb7c3 /drivers/clk | |
parent | 08442ce993deeb15a070c14cc3f3459e87d111e0 (diff) |
clk: fix new_parent dereference before null check
Commit 71472c0 (clk: add support for clock reparent on set_rate) added a
dereference of the new_parent pointer in clk_reparent(), but as detected
by smatch clk_reparent() later checks whether new_parent is NULL.
The dereference was in order to clear the new parent's new_child pointer
to avoid duplicate POST_RATE_CHANGE notifications, so clearly isn't
necessary if the new parent is NULL, so move it inside the "if
(new_parent)" block.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 2db08c01ef51..02e75d4e0a77 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -1108,16 +1108,17 @@ static u8 clk_fetch_parent_index(struct clk *clk, struct clk *parent) | |||
1108 | 1108 | ||
1109 | static void clk_reparent(struct clk *clk, struct clk *new_parent) | 1109 | static void clk_reparent(struct clk *clk, struct clk *new_parent) |
1110 | { | 1110 | { |
1111 | /* avoid duplicate POST_RATE_CHANGE notifications */ | ||
1112 | if (new_parent->new_child == clk) | ||
1113 | new_parent->new_child = NULL; | ||
1114 | |||
1115 | hlist_del(&clk->child_node); | 1111 | hlist_del(&clk->child_node); |
1116 | 1112 | ||
1117 | if (new_parent) | 1113 | if (new_parent) { |
1114 | /* avoid duplicate POST_RATE_CHANGE notifications */ | ||
1115 | if (new_parent->new_child == clk) | ||
1116 | new_parent->new_child = NULL; | ||
1117 | |||
1118 | hlist_add_head(&clk->child_node, &new_parent->children); | 1118 | hlist_add_head(&clk->child_node, &new_parent->children); |
1119 | else | 1119 | } else { |
1120 | hlist_add_head(&clk->child_node, &clk_orphan_list); | 1120 | hlist_add_head(&clk->child_node, &clk_orphan_list); |
1121 | } | ||
1121 | 1122 | ||
1122 | clk->parent = new_parent; | 1123 | clk->parent = new_parent; |
1123 | } | 1124 | } |