All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 8/8] clk: clocking-wizard: Use separate notifier_block for each clock
Date: Thu, 09 Jul 2026 11:20:22 +0000	[thread overview]
Message-ID: <20260709112023.02B421F00ADB@smtp.kernel.org> (raw)
In-Reply-To: <20260709111403.1579159-9-shubhrajyoti.datta@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect `container_of` cast when reusing the same notifier callback for a new `notifier_block`, resulting in a misaligned `struct clk_wzrd` pointer and out-of-bounds memory accesses.
--

--- Patch [8]: [PATCH v2 8/8] clk: clocking-wizard: Use separate notifier_block for each clock ---
commit f1481850744c067369ec043b5f8c6bf3ee19d10b
Author: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>

clk: clocking-wizard: Use separate notifier_block for each clock

This commit introduces a dedicated notifier_block, nb_axi, for the
s_axi_aclk chain. This prevents linked list corruption that occurs
when registering a single notifier block to multiple chains.

> diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> index 289c32ab5cd80..bcbfb4341dbab 100644
> --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> @@ -137,6 +138,7 @@ enum clk_wzrd_int_clks {
>   */
>  struct clk_wzrd {
>  	struct notifier_block nb;
> +	struct notifier_block nb_axi;
>  	void __iomem *base;

[ ... ]

> @@ -1318,8 +1320,10 @@ static int clk_wzrd_probe(struct platform_device *pdev)
>  				dev_warn(&pdev->dev,
>  					 "unable to register clock notifier\n");
>  
> +			clk_wzrd->nb_axi.notifier_call = clk_wzrd_clk_notifier;
> +
>  			ret = devm_clk_notifier_register(&pdev->dev, clk_wzrd->axi_clk,
> -							 &clk_wzrd->nb);
> +							 &clk_wzrd->nb_axi);

[Severity: High]
Does sharing clk_wzrd_clk_notifier for nb_axi lead to an incorrect
container_of() cast?

Looking at clk_wzrd_clk_notifier(), it uses to_clk_wzrd(nb), which is
hardcoded to expect the original nb field:

#define to_clk_wzrd(_nb) container_of(_nb, struct clk_wzrd, nb)

Since nb_axi is at a non-zero offset in struct clk_wzrd (unlike nb), won't 
using the same callback for nb_axi result in a misaligned struct clk_wzrd 
pointer? 

It seems this would lead to out-of-bounds memory accesses and incorrectly 
skipped frequency bounds checks when the s_axi_aclk chain triggers a rate 
change.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709111403.1579159-1-shubhrajyoti.datta@amd.com?part=8

      reply	other threads:[~2026-07-09 11:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 11:13 [PATCH v2 0/8] clk: clocking-wizard: Add static-config clock provider support Shubhrajyoti Datta
2026-07-09 11:13 ` [PATCH v2 1/8] dt-bindings: clock: clocking-wizard: Add static-config mode support Shubhrajyoti Datta
2026-07-09 11:13 ` [PATCH v2 2/8] clk: clocking-wizard: Do not map the memory for static-config Shubhrajyoti Datta
2026-07-09 11:28   ` sashiko-bot
2026-07-09 11:13 ` [PATCH v2 3/8] clk: clocking-wizard: Move clk_in1 acquisition before static-config check Shubhrajyoti Datta
2026-07-09 11:25   ` sashiko-bot
2026-07-09 11:13 ` [PATCH v2 4/8] clk: clocking-wizard: Add static-config clock provider support Shubhrajyoti Datta
2026-07-09 11:26   ` sashiko-bot
2026-07-09 11:14 ` [PATCH v2 5/8] clk: clocking-wizard: Skip s_axi_aclk for static-config Shubhrajyoti Datta
2026-07-09 11:28   ` sashiko-bot
2026-07-09 11:14 ` [PATCH v2 6/8] clk: clocking-wizard: Use dev_err_probe() when mapping registers Shubhrajyoti Datta
2026-07-09 11:25   ` sashiko-bot
2026-07-09 11:14 ` [PATCH v2 7/8] clk: clocking-wizard: Fix division by zero and unbounded register write Shubhrajyoti Datta
2026-07-09 11:28   ` sashiko-bot
2026-07-09 11:14 ` [PATCH v2 8/8] clk: clocking-wizard: Use separate notifier_block for each clock Shubhrajyoti Datta
2026-07-09 11:20   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260709112023.02B421F00ADB@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shubhrajyoti.datta@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.