From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: fix new_parent dereference before null check
Date: Fri, 30 Aug 2013 12:59:09 -0700 [thread overview]
Message-ID: <20130830195909.10934.38599@quantum> (raw)
In-Reply-To: <1377774651-5394-1-git-send-email-james.hogan@imgtec.com>
Quoting James Hogan (2013-08-29 04:10:51)
> 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>
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: linux-arm-kernel at lists.infradead.org
Thanks for the quick fix. I've pulled this into clk-next.
Regards,
Mike
> ---
> drivers/clk/clk.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 2db08c0..02e75d4 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)
>
> static void clk_reparent(struct clk *clk, struct clk *new_parent)
> {
> - /* avoid duplicate POST_RATE_CHANGE notifications */
> - if (new_parent->new_child == clk)
> - new_parent->new_child = NULL;
> -
> hlist_del(&clk->child_node);
>
> - if (new_parent)
> + if (new_parent) {
> + /* avoid duplicate POST_RATE_CHANGE notifications */
> + if (new_parent->new_child == clk)
> + new_parent->new_child = NULL;
> +
> hlist_add_head(&clk->child_node, &new_parent->children);
> - else
> + } else {
> hlist_add_head(&clk->child_node, &clk_orphan_list);
> + }
>
> clk->parent = new_parent;
> }
> --
> 1.8.1.2
prev parent reply other threads:[~2013-08-30 19:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-29 11:10 [PATCH] clk: fix new_parent dereference before null check James Hogan
2013-08-30 19:59 ` Mike Turquette [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130830195909.10934.38599@quantum \
--to=mturquette@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.