[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202412080533.Inh1JBwa-lkp@intel.com>
Date: Mon, 9 Dec 2024 12:30:34 +0800
From: kernel test robot <lkp@...el.com>
To: Théo Lebrun <theo.lebrun@...tlin.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Stephen Boyd <sboyd@...nel.org>
Subject: drivers/clk/clk-eyeq.c:131 eqc_pll_downshift_factors() warn: always
true condition '(*mult <= (~0)) => (0-u32max <= u32max)'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7503345ac5f5e82fd9a36d6e6b447c016376403a
commit: 25d904946a0baf08b16204d95dc3624096d99c38 clk: eyeq: add driver
date: 6 weeks ago
config: nios2-randconfig-r073-20241206 (https://download.01.org/0day-ci/archive/20241208/202412080533.Inh1JBwa-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412080533.Inh1JBwa-lkp@intel.com/
smatch warnings:
drivers/clk/clk-eyeq.c:131 eqc_pll_downshift_factors() warn: always true condition '(*mult <= (~0)) => (0-u32max <= u32max)'
drivers/clk/clk-eyeq.c:131 eqc_pll_downshift_factors() warn: always true condition '(*div <= (~0)) => (0-u32max <= u32max)'
drivers/clk/clk-eyeq.c:374 eqc_probe() warn: 'base' from ioremap() not released on lines: 358.
vim +131 drivers/clk/clk-eyeq.c
112
113 /*
114 * Both factors (mult and div) must fit in 32 bits. When an operation overflows,
115 * this function throws away low bits so that factors still fit in 32 bits.
116 *
117 * Precision loss depends on amplitude of mult and div. Worst theorical
118 * loss is: (UINT_MAX+1) / UINT_MAX - 1 = 2.3e-10.
119 * This is 1Hz every 4.3GHz.
120 */
121 static void eqc_pll_downshift_factors(unsigned long *mult, unsigned long *div)
122 {
123 unsigned long biggest;
124 unsigned int shift;
125
126 /* This function can be removed if mult/div switch to unsigned long. */
127 static_assert(sizeof_field(struct clk_fixed_factor, mult) == sizeof(unsigned int));
128 static_assert(sizeof_field(struct clk_fixed_factor, div) == sizeof(unsigned int));
129
130 /* No overflow, nothing to be done. */
> 131 if (*mult <= UINT_MAX && *div <= UINT_MAX)
132 return;
133
134 /*
135 * Compute the shift required to bring the biggest factor into unsigned
136 * int range. That is, shift its highest set bit to the unsigned int
137 * most significant bit.
138 */
139 biggest = max(*mult, *div);
140 shift = __fls(biggest) - (BITS_PER_BYTE * sizeof(unsigned int)) + 1;
141
142 *mult >>= shift;
143 *div >>= shift;
144 }
145
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists