public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer
@ 2026-05-12 11:00 Nishanth Menon
  2026-05-12 14:53 ` Brian Masney
  2026-06-04  2:59 ` Nishanth Menon
  0 siblings, 2 replies; 3+ messages in thread
From: Nishanth Menon @ 2026-05-12 11:00 UTC (permalink / raw)
  To: Brian Masney, Stephen Boyd, Michael Turquette
  Cc: Santosh Shilimkar, Tero Kristo, Nishanth Menon, linux-clk,
	linux-kernel, linux-arm-kernel, afd, sozdayvek, Jing Yangyang,
	Zeal Robot, kernel test robot, Julia Lawall, David Yang

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

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@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/
Reviewed-by: Stepan Ionichev <sozdayvek@gmail•com>
Reviewed-by: Andrew Davis <afd@ti•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>
---
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@ti.com/

 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer
  2026-05-12 11:00 [PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer Nishanth Menon
@ 2026-05-12 14:53 ` Brian Masney
  2026-06-04  2:59 ` Nishanth Menon
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Masney @ 2026-05-12 14:53 UTC (permalink / raw)
  To: Nishanth Menon
  Cc: Stephen Boyd, Michael Turquette, Santosh Shilimkar, Tero Kristo,
	linux-clk, linux-kernel, linux-arm-kernel, afd, sozdayvek,
	Jing Yangyang, Zeal Robot, kernel test robot, Julia Lawall,
	David Yang

On Tue, May 12, 2026 at 06:00:28AM -0500, 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
> 
> 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@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/
> Reviewed-by: Stepan Ionichev <sozdayvek@gmail•com>
> Reviewed-by: Andrew Davis <afd@ti•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>

Reviewed-by: Brian Masney <bmasney@redhat•com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer
  2026-05-12 11:00 [PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer Nishanth Menon
  2026-05-12 14:53 ` Brian Masney
@ 2026-06-04  2:59 ` Nishanth Menon
  1 sibling, 0 replies; 3+ messages in thread
From: Nishanth Menon @ 2026-06-04  2:59 UTC (permalink / raw)
  To: Brian Masney, Stephen Boyd, Michael Turquette, Nishanth Menon
  Cc: Santosh Shilimkar, Tero Kristo, linux-clk, linux-kernel,
	linux-arm-kernel, afd, sozdayvek, Jing Yangyang, Zeal Robot,
	kernel test robot, Julia Lawall, David Yang

Hi Nishanth Menon,

On Tue, 12 May 2026 06:00:28 -0500, Nishanth Menon wrote:
> 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 *)).
> 
> [...]

I have applied the following to branch ti-k3-sci-clk-next on [1].
Thank you!

[1/1] clk: keystone: sci-clk: fix application of sizeof to pointer
      commit: 2b0123e4a9257fa2933d13d1bca9ac36467efac1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent up the chain during
the next merge window (or sooner if it is a relevant bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
https://ti.com/opensource



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-04  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 11:00 [PATCH V2] clk: keystone: sci-clk: fix application of sizeof to pointer Nishanth Menon
2026-05-12 14:53 ` Brian Masney
2026-06-04  2:59 ` Nishanth Menon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox