[PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer
Brian Masney
bmasney at redhat.com
Tue May 12 07:53:08 PDT 2026
On Tue, May 12, 2026 at 06:00:28AM -0500, Nishanth Menon wrote:
> From: Jing Yangyang <jing.yangyang at zte.com.cn>
>
> Coccinelle (scripts/coccinelle/misc/noderef.cocci) reports:
>
> drivers/clk/keystone/sci-clk.c:391:8-14: ERROR: application of
> sizeof to pointer
>
> In sci_clk_get(), 'clk' is declared as 'struct sci_clk **', so
> sizeof(clk) is sizeof(struct sci_clk **) which is the size of a
> pointer rather than the size of an array element. provider->clocks
> is an array of 'struct sci_clk *', so the canonical size argument
> to bsearch() is sizeof(*clk) (i.e. sizeof(struct sci_clk *)).
>
> The two values are equal on every supported architecture, so this
> is correctness/idiom, not a runtime fix, but the new form matches
> the rest of the bsearch() callers in the tree and silences the
> Coccinelle warning the script flagged.
>
> Reported-by: Zeal Robot <zealci at zte.com.cn>
> Closes: https://lore.kernel.org/all/84a6ba16686347099a3dab2e5161a930e792eb6e.1629198281.git.jing.yangyang@zte.com.cn/
> Reported-by: kernel test robot <lkp at intel.com>
> Reported-by: Julia Lawall <julia.lawall at inria.fr>
> Closes: https://lore.kernel.org/all/202512040525.zrHSDl5h-lkp@intel.com/
> Link: https://lore.kernel.org/linux-clk/20211012021931.176727-1-davidcomponentone@gmail.com/
> Reviewed-by: Stepan Ionichev <sozdayvek at gmail.com>
> Reviewed-by: Andrew Davis <afd at ti.com>
> Signed-off-by: Jing Yangyang <jing.yangyang at zte.com.cn>
> Signed-off-by: David Yang <davidcomponentone at gmail.com>
> [nm at ti.com: Improved commit message]
> Signed-off-by: Nishanth Menon <nm at ti.com>
Reviewed-by: Brian Masney <bmasney at redhat.com>
More information about the linux-arm-kernel
mailing list