drivers/clk/keystone/sci-clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
From: Jing Yangyang <jing.yangyang@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
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@zte.com.cn>
Closes: https://lore.kernel.org/all/84a6ba16686347099a3dab2e5161a930e792eb6e.1629198281.git.jing.yangyang@zte.com.cn/
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@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/
Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
[nm@ti.com: Improved commit message]
Signed-off-by: Nishanth Menon <nm@ti.com>
---
Cc: Jing Yangyang <cgel.zte@gmail.com>
Cc: Ran Sun <sunran001@208suo.com>
- Functionality: No impact (on Linux architectures), thus no Fixes/Stable tag.
- 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);
--
2.47.0
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. Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com> Stepan
On 5/8/26 10:23 AM, Nishanth Menon wrote: > From: Jing Yangyang <jing.yangyang@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 > > 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@zte.com.cn> > Closes: https://lore.kernel.org/all/84a6ba16686347099a3dab2e5161a930e792eb6e.1629198281.git.jing.yangyang@zte.com.cn/ > Reported-by: kernel test robot <lkp@intel.com> > Reported-by: Julia Lawall <julia.lawall@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/ > Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn> > Signed-off-by: David Yang <davidcomponentone@gmail.com> > [nm@ti.com: Improved commit message] > Signed-off-by: Nishanth Menon <nm@ti.com> > --- > Cc: Jing Yangyang <cgel.zte@gmail.com> > Cc: Ran Sun <sunran001@208suo.com> > > - 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@ti.com> > - 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);
On 11:59-20260508, Andrew Davis wrote: [...] > > - 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 Yep (also why i put it in diffstat notes ;) ) - any sane system (which is what we support in Linux ;) ) - though C standard does'nt explicitly call that out from what I could gather, it is practically what all systems tend to do. i had the extreme paranoia about this and got claude[1] to check it out using clang.. Results match the expectation. > correct and silence a Coccinelle warning. Anyway, Yep, That is all this is.. patches keep popping up every few years. > > Reviewed-by: Andrew Davis <afd@ti.com> > Thanks. [1] https://gist.githubusercontent.com/nmenon/afa9ac915e189334f048c177f16fe54f/raw/ccd08843ff7193090f9fbdca3f5c76d0a4366c85/quick%2520check%2520with%2520clang -- Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D https://ti.com/opensource
© 2016 - 2026 Red Hat, Inc.