Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCHv3 2/6] serial: mxs-auart: rework clock handling in mxs_get_clks and probe
Date: Thu, 11 Jun 2026 03:49:23 +0000	[thread overview]
Message-ID: <20260611034923.C20F01F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611033856.6476-3-rosenp@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [Medium] Unconditional clock enablement in probe introduces a reference leak and power management regression for non-ASM9260 devices on driver removal.

Pre-existing issues:
- [Critical] Out-of-bounds array write or incorrect array cleanup due to a mismatch between `s->port.line` and `pdev->id`.
- [High] Potential kernel panic due to a Use-After-Unmap condition in the interrupt handler during device removal or probe failure.
--

commit 7ff1436c03e590a8440db3420eec3a2408bf70ee
Author: Rosen Penev <rosenp@gmail.com>

serial: mxs-auart: rework clock handling in mxs_get_clks and probe

This commit updates the driver to use devm_clk_get_enabled for the AHB
clock so its enable/disable lifetime is managed by the driver model. It
also moves the mod clock prepare_enable out of mxs_get_clks and into
probe to avoid CLK_SET_RATE_GATE failures.

> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c

[ ... ]

> @@ -1697,10 +1686,8 @@ static void mxs_auart_remove(struct platform_device *pdev)
>  	struct mxs_auart_port *s = platform_get_drvdata(pdev);
>  
>  	uart_remove_one_port(&auart_driver, &s->port);
>  	auart_port[pdev->id] = NULL;

[Severity: Critical]
This isn't a bug introduced by this patch, but does this clear the wrong
array entry?

In mxs_auart_probe(), the entry is set using the alias ID:
    auart_port[s->port.line] = s;

If pdev->id is -1 for device tree instantiated platform devices, wouldn't
this cause an out of bounds memory write into the BSS segment?

>  	mxs_auart_free_gpio_irq(s);
>  	iounmap(s->port.membase);

[Severity: High]
This is a pre-existing issue, but can this cause a use-after-unmap during
device removal?

Since the interrupt was requested using devm_request_irq() in probe, the
devres core will keep it active until after mxs_auart_remove() fully returns.

If an interrupt fires during this window, wouldn't mxs_auart_irq_handle()
attempt to read from the hardware registers using the explicitly unmapped
membase?

> -	if (is_asm9260_auart(s)) {
> +	if (is_asm9260_auart(s))
>  		clk_disable_unprepare(s->clk);
> -		clk_disable_unprepare(s->clk_ahb);
> -	}
>  }

[Severity: Medium]
Since s->clk is now unconditionally prepared and enabled for all device
variants during mxs_auart_probe(), shouldn't it be unconditionally disabled
here?

Guarding it behind is_asm9260_auart() seems like it will permanently leak
the clock enable reference for non-ASM9260 devices on module unload.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260611033856.6476-3-rosenp@gmail.com?part=1

  reply	other threads:[~2026-06-11  3:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  3:38 [PATCHv3 0/6] serial: mxs-auart: devm conversion, clock rework, and IRQ ordering fixes Rosen Penev
2026-06-11  3:38 ` [PATCHv3 1/6] serial: mxs-auart: fix cast type for of_device_get_match_data Rosen Penev
2026-06-11  3:50   ` sashiko-bot
2026-06-11  3:38 ` [PATCHv3 2/6] serial: mxs-auart: rework clock handling in mxs_get_clks and probe Rosen Penev
2026-06-11  3:49   ` sashiko-bot [this message]
2026-06-11  3:38 ` [PATCHv3 3/6] serial: mxs-auart: use devm resources for iomem and GPIO IRQs Rosen Penev
2026-06-11  3:38 ` [PATCHv3 4/6] serial: mxs-auart: fix IRQ registration ordering and manage console clock Rosen Penev
2026-06-11  3:38 ` [PATCHv3 5/6] serial: mxs-auart: clamp RX DMA count to buffer size Rosen Penev
2026-06-11  3:49   ` sashiko-bot
2026-06-11  3:38 ` [PATCHv3 6/6] serial: mxs-auart: terminate DMA before releasing channels in exit Rosen Penev
2026-06-11  4:00   ` sashiko-bot

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=20260611034923.C20F01F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=rosenp@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox