From: Vladimir Zapolskiy <vz@mleia.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-clk@vger.kernel.org
Subject: [PATCH 1/3] clk: don't fetch parent index for non multi-parent clocks
Date: Thu, 7 Jan 2016 05:16:06 +0200 [thread overview]
Message-ID: <1452136568-478-2-git-send-email-vz@mleia.com> (raw)
In-Reply-To: <1452136568-478-1-git-send-email-vz@mleia.com>
If clk_set_parent(clk, parent) is called when 'clk' is a root clock or
'clk' has a single parent different from 'parent' clock, a vain
attempt to find 'parent' index is still performed, which causes
either an allocation of 0-byte size lookup array or never used
sizeof(struct clk*) array.
Like in case of invalid clk_set_parent() of a multi-parent clock,
return -EINVAL in the cases described above without trying to allocate
a lookup table.
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
drivers/clk/clk.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b4db67a..129ac0a 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1794,8 +1794,13 @@ static int clk_core_set_parent(struct clk_core *core, struct clk_core *parent)
if (core->parent == parent)
goto out;
+ if (core->num_parents <= 1) {
+ ret = -EINVAL;
+ goto out;
+ }
+
/* verify ops for for multi-parent clks */
- if ((core->num_parents > 1) && (!core->ops->set_parent)) {
+ if (!core->ops->set_parent) {
ret = -ENOSYS;
goto out;
}
--
2.1.4
next prev parent reply other threads:[~2016-01-07 3:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 3:16 [PATCH 0/3] clk: remove dead code allocations of parent lookup tables Vladimir Zapolskiy
2016-01-07 3:16 ` Vladimir Zapolskiy [this message]
2016-01-07 3:16 ` [PATCH 2/3] clk: simplify array allocation of clock parents for lookup Vladimir Zapolskiy
2016-01-07 3:16 ` [PATCH 3/3] clk: remove redundant clock parents lookup table allocations Vladimir Zapolskiy
2016-01-07 9:00 ` Masahiro Yamada
2016-01-07 10:44 ` Vladimir Zapolskiy
2016-01-07 11:33 ` Masahiro Yamada
2016-01-07 13:45 ` Vladimir Zapolskiy
2016-01-08 0:33 ` [PATCH 0/3] clk: remove dead code allocations of parent lookup tables Vladimir Zapolskiy
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=1452136568-478-2-git-send-email-vz@mleia.com \
--to=vz@mleia.com \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.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