[PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer

From: Nishanth Menon

Date: Tue May 12 2026 - 07:02:04 EST


From: Jing Yangyang <jing.yangyang@xxxxxxxxxx>

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@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/84a6ba16686347099a3dab2e5161a930e792eb6e.1629198281.git.jing.yangyang@xxxxxxxxxx/
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Julia Lawall <julia.lawall@xxxxxxxx>
Closes: https://lore.kernel.org/all/202512040525.zrHSDl5h-lkp@xxxxxxxxx/
Link: https://lore.kernel.org/linux-clk/20211012021931.176727-1-davidcomponentone@xxxxxxxxx/
Reviewed-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
Reviewed-by: Andrew Davis <afd@xxxxxx>
Signed-off-by: Jing Yangyang <jing.yangyang@xxxxxxxxxx>
Signed-off-by: David Yang <davidcomponentone@xxxxxxxxx>
[nm@xxxxxx: Improved commit message]
Signed-off-by: Nishanth Menon <nm@xxxxxx>
---
Changes in V2:
- Picked up Stepan's suggestion on commit message
- Picked up Andrew and Stepan's reviewed-by
V1: https://lore.kernel.org/all/20260508152321.3683799-1-nm@xxxxxx/

drivers/clk/keystone/sci-clk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
index 9d5071223f4c..2fc1f050779b 100644
--- a/drivers/clk/keystone/sci-clk.c
+++ b/drivers/clk/keystone/sci-clk.c
@@ -388,7 +388,7 @@ static struct clk_hw *sci_clk_get(struct of_phandle_args *clkspec, void *data)
key.clk_id = clkspec->args[1];

clk = bsearch(&key, provider->clocks, provider->num_clocks,
- sizeof(clk), _cmp_sci_clk);
+ sizeof(*clk), _cmp_sci_clk);

if (!clk)
return ERR_PTR(-ENODEV);
--
2.32.0