From: trix@redhat.com
To: mturquette@baylibre.com, sboyd@kernel.org,
nobuhiro1.iwamatsu@toshiba.co.jp, nathan@kernel.org,
ndesaulniers@google.com
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Tom Rix <trix@redhat.com>
Subject: [PATCH] clk: visconti: fix array's data insert check
Date: Fri, 7 Jan 2022 12:49:39 -0800 [thread overview]
Message-ID: <20220107204939.3939151-1-trix@redhat.com> (raw)
From: Tom Rix <trix@redhat.com>
Clang build fails with
pll.c:292:20: error: address of array 'ctx->clk_data.hws' will
always evaluate to 'true'
if (ctx->clk_data.hws && id)
~~~~~~~~~~~~~~^~~ ~~
This check protects inserting into the clk_data.hws array.
clk_data is allocated a trailing element of the ctx struct.
If the ctx is ok, the ctx->clk_data.hws will be ok.
Change to checking if 'id' falls outside of the array
bounds.
Fixes: b4cbe606dc36 ("clk: visconti: Add support common clock driver and reset driver")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/clk/visconti/pll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/visconti/pll.c b/drivers/clk/visconti/pll.c
index 3b6e88bb73d5b..7f2e1016536ab 100644
--- a/drivers/clk/visconti/pll.c
+++ b/drivers/clk/visconti/pll.c
@@ -289,7 +289,7 @@ static void visconti_pll_add_lookup(struct visconti_pll_provider *ctx,
struct clk_hw *hw_clk,
unsigned int id)
{
- if (ctx->clk_data.hws && id)
+ if (id < ctx->clk_data.num)
ctx->clk_data.hws[id] = hw_clk;
}
--
2.26.3
reply other threads:[~2022-01-07 20:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220107204939.3939151-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mturquette@baylibre.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nobuhiro1.iwamatsu@toshiba.co.jp \
--cc=sboyd@kernel.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
Powered by JetHome