mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Måns Rullgård" <mans@mansr.com>
To: Michael Turquette <mturquette@baylibre.com>
Cc: Rhyland Klein <rklein@nvidia.com>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: check for invalid parent index of orphans in __clk_init()
Date: Tue, 15 Sep 2015 15:37:58 +0100	[thread overview]
Message-ID: <yw1xzj0nu4s9.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <20150413191250.19585.71603@quantum> (Michael Turquette's message of "Mon, 13 Apr 2015 12:12:50 -0700")

Michael Turquette <mturquette@linaro.org> writes:

> Quoting Rhyland Klein (2015-02-17 08:58:29)
>> On 2/15/2015 7:33 AM, Mans Rullgard wrote:
>> > If a mux clock is initialised (by hardware or firmware) with an
>> > invalid parent, its ->get_parent() can return an out of range
>> > index.  For example, the generic mux clock attempts to return
>> > -EINVAL, which due to the u8 return type ends up a rather large
>> > number.  Using this index with the parent_names[] array results
>> > in an invalid pointer and (usually) a crash in the following
>> > strcmp().
>> > 
>> > This patch adds a check for the parent index being in range,
>> > ignoring clocks reporting invalid values.
>> > 
>> > Signed-off-by: Mans Rullgard <mans@mansr.com>
>> > Cc: Rhyland Klein <rklein@nvidia.com>
>> > ---
>> >  drivers/clk/clk.c | 3 ++-
>> >  1 file changed, 2 insertions(+), 1 deletion(-)
>> > 
>> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>> > index d48ac71..bc0662b 100644
>> > --- a/drivers/clk/clk.c
>> > +++ b/drivers/clk/clk.c
>> > @@ -1950,7 +1950,8 @@ int __clk_init(struct device *dev, struct clk *clk)
>> >       hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
>> >               if (orphan->num_parents && orphan->ops->get_parent) {
>> >                       i = orphan->ops->get_parent(orphan->hw);
>> > -                     if (!strcmp(clk->name, orphan->parent_names[i]))
>> > +                     if (i >= 0 && i < orphan->num_parents &&
>> > +                         !strcmp(clk->name, orphan->parent_names[i]))
>> >                               __clk_reparent(orphan, clk);
>> >                       continue;
>> >               }
>> > 
>> 
>> This works for me and is less invasive than the original patch series.
>> 
>> Tested-by: Rhyland Klein <rklein@nvidia.com>
>
> Applied.

Did this get lost somewhere?  It's not in mainline, and I can't find it
in the clk tree on kernel.org either.

-- 
Måns Rullgård
mans@mansr.com

  reply	other threads:[~2015-09-15 14:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-15 12:33 Mans Rullgard
2015-02-17 16:58 ` Rhyland Klein
2015-04-13 19:12   ` Michael Turquette
2015-09-15 14:37     ` Måns Rullgård [this message]
2015-09-17 22:25       ` Stephen Boyd

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=yw1xzj0nu4s9.fsf@unicorn.mansr.com \
    --to=mans@mansr.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=rklein@nvidia.com \
    --cc=sboyd@codeaurora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®