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

From: Andrew Davis

Date: Fri May 08 2026 - 12:59:52 EST


On 5/8/26 10:23 AM, Nishanth Menon wrote:
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

provider->clocks is an array of struct sci_clk *, so bsearch()
expects the size of each element (struct sci_clk *). However,
sizeof(clk) evaluates to the size of a pointer-to-pointer.

Use sizeof(*clk) to pass the correct element size.

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/
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>
---
Cc: Jing Yangyang <cgel.zte@xxxxxxxxx>
Cc: Ran Sun <sunran001@xxxxxxxxxx>

- Functionality: No impact (on Linux architectures), thus no Fixes/Stable tag.

Not sure what "on Linux architectures" means here, this should be true for any
sane system, right? You are going from the sizeof(pointer-to-pointer) to the
sizeof(pointer), both should be equal. This is just to be more technically
correct and silence a Coccinelle warning. Anyway,

Reviewed-by: Andrew Davis <afd@xxxxxx>

- History: This patch has long-standing history; I have attributed it to the
earliest valid author found during a recent scrub.
- Reports: Retained chronological attribution even where public reports (Zeal
Robot) are unavailable.
- Checkpatch: Acknowledging minor warning regarding tag ordering (Reported-by
/ Closes sequence); chosen to maintain link integrity for automated tools.
- Testing: Verified on available K3 SoCs against 2026-05-07:
https://gist.github.com/nmenon/afa9ac915e189334f048c177f16fe54f

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);