clk: fix new_parent dereference before null check
authorJames Hogan <james.hogan@imgtec.com>
Thu, 29 Aug 2013 11:10:51 +0000 (12:10 +0100)
committer黄涛 <huangtao@rock-chips.com>
Wed, 8 Jan 2014 03:04:43 +0000 (11:04 +0800)
commit025dbbf707aba5dde8a9b9b30bfbb0ed9bd8b87e
tree2f39ffaa29b6d1d3cbc04fc60df188004a908a4c
parenta79d253168c3ee65c474d67f362736e9efd46818
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>
drivers/clk/clk.c