From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Qin Jian <qinjian@cqplus1.com>, sboyd@kernel.org
Cc: lkp@intel.com, kbuild-all@lists.01.org, mturquette@baylibre.com,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Qin Jian <qinjian@cqplus1.com>
Subject: Re: [PATCH] clk: Add Sunplus SP7021 clock driver
Date: Mon, 22 Aug 2022 11:40:14 +0300 [thread overview]
Message-ID: <202208212144.aUofUlUt-lkp@intel.com> (raw)
In-Reply-To: <20220817070113.415971-1-qinjian@cqplus1.com>
Hi Qin,
url: https://github.com/intel-lab-lkp/linux/commits/Qin-Jian/clk-Add-Sunplus-SP7021-clock-driver/20220817-151010
base: 568035b01cfb107af8d2e4bd2fb9aea22cf5b868
config: arm64-randconfig-m031-20220821 (https://download.01.org/0day-ci/archive/20220821/202208212144.aUofUlUt-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/clk/clk-sp7021.c:171 plltv_integer_div() error: buffer overflow 'm_table' 19 <= 19 (assuming for loop doesn't break)
vim +171 drivers/clk/clk-sp7021.c
5673230d6a56d6 Qin Jian 2022-08-17 145 static long plltv_integer_div(struct sp_pll *clk, unsigned long freq)
5673230d6a56d6 Qin Jian 2022-08-17 146 {
5673230d6a56d6 Qin Jian 2022-08-17 147 /* valid m values: 27M must be divisible by m */
5673230d6a56d6 Qin Jian 2022-08-17 148 static const u32 m_table[] = {
5673230d6a56d6 Qin Jian 2022-08-17 149 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32
5673230d6a56d6 Qin Jian 2022-08-17 150 };
5673230d6a56d6 Qin Jian 2022-08-17 151 u32 m, n, r;
5673230d6a56d6 Qin Jian 2022-08-17 152 unsigned long fvco, nf;
5673230d6a56d6 Qin Jian 2022-08-17 153 long ret;
5673230d6a56d6 Qin Jian 2022-08-17 154
5673230d6a56d6 Qin Jian 2022-08-17 155 freq = clamp(freq, F_MIN, F_MAX);
5673230d6a56d6 Qin Jian 2022-08-17 156
5673230d6a56d6 Qin Jian 2022-08-17 157 /* DIVR 0~3 */
5673230d6a56d6 Qin Jian 2022-08-17 158 for (r = 0; r <= 3; r++) {
5673230d6a56d6 Qin Jian 2022-08-17 159 fvco = freq << r;
5673230d6a56d6 Qin Jian 2022-08-17 160 if (fvco <= FVCO_MAX)
5673230d6a56d6 Qin Jian 2022-08-17 161 break;
5673230d6a56d6 Qin Jian 2022-08-17 162 }
5673230d6a56d6 Qin Jian 2022-08-17 163
5673230d6a56d6 Qin Jian 2022-08-17 164 /* DIVM */
5673230d6a56d6 Qin Jian 2022-08-17 165 for (m = 0; m < ARRAY_SIZE(m_table); m++) {
5673230d6a56d6 Qin Jian 2022-08-17 166 nf = fvco * m_table[m];
5673230d6a56d6 Qin Jian 2022-08-17 167 n = nf / F_27M;
5673230d6a56d6 Qin Jian 2022-08-17 168 if ((n * F_27M) == nf)
5673230d6a56d6 Qin Jian 2022-08-17 169 break;
5673230d6a56d6 Qin Jian 2022-08-17 170 }
5673230d6a56d6 Qin Jian 2022-08-17 @171 m = m_table[m];
^^^^^^^^^^^^^^^
If we know the for loop is going to break then why bother with a limit?
5673230d6a56d6 Qin Jian 2022-08-17 172
5673230d6a56d6 Qin Jian 2022-08-17 173 if (!m) {
5673230d6a56d6 Qin Jian 2022-08-17 174 ret = -EINVAL;
5673230d6a56d6 Qin Jian 2022-08-17 175 goto err_not_found;
5673230d6a56d6 Qin Jian 2022-08-17 176 }
5673230d6a56d6 Qin Jian 2022-08-17 177
5673230d6a56d6 Qin Jian 2022-08-17 178 /* save parameters */
5673230d6a56d6 Qin Jian 2022-08-17 179 clk->p[SEL_FRA] = 0;
5673230d6a56d6 Qin Jian 2022-08-17 180 clk->p[DIVR] = r;
5673230d6a56d6 Qin Jian 2022-08-17 181 clk->p[DIVN] = n;
5673230d6a56d6 Qin Jian 2022-08-17 182 clk->p[DIVM] = m;
5673230d6a56d6 Qin Jian 2022-08-17 183
5673230d6a56d6 Qin Jian 2022-08-17 184 return freq;
5673230d6a56d6 Qin Jian 2022-08-17 185
5673230d6a56d6 Qin Jian 2022-08-17 186 err_not_found:
5673230d6a56d6 Qin Jian 2022-08-17 187 pr_err("%s: %s freq:%lu not found a valid setting\n",
5673230d6a56d6 Qin Jian 2022-08-17 188 __func__, clk_hw_get_name(&clk->hw), freq);
5673230d6a56d6 Qin Jian 2022-08-17 189
5673230d6a56d6 Qin Jian 2022-08-17 190 return ret;
5673230d6a56d6 Qin Jian 2022-08-17 191 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
next prev parent reply other threads:[~2022-08-22 8:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-17 7:01 [PATCH] clk: Add Sunplus SP7021 clock driver Qin Jian
2022-08-17 20:23 ` kernel test robot
2022-08-22 8:40 ` Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-10-22 9:07 qinjian
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=202208212144.aUofUlUt-lkp@intel.com \
--to=dan.carpenter@oracle.com \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mturquette@baylibre.com \
--cc=qinjian@cqplus1.com \
--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