All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Greg Ungerer" <gerg@linux-m68k.org>, linux-serial@vger.kernel.org
Subject: Re: [PATCH 5/5] serial: mcf: add devicetree support
Date: Tue, 13 Oct 2026 12:49:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-169741@kernel.org> (raw)
In-Reply-To: <20261013120831.1046590-6-gerg@linux-m68k.org>

Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] tty: serial: mcf: ID collision due to persistent pdev->id mutation on probe deferral
- [High] tty: serial: mcf: dangling pointer in global mcf_ports array on probe error
- [High] tty: serial: mcf: mcf_remove unregisters all ports system-wide instead of unbound device
- [High] serial: mcf: broken port numbering and API violations in mcf_probe
- [Medium] tty: serial: mcf: missing MODULE_DEVICE_TABLE prevents module autoloading
- [Medium] tty: serial: mcf: missing error check for uart_add_one_port
--

commit 61f92ee3964b5b13fd6350da88b718b7350512cd
Author: Greg Ungerer <gerg@linux-m68k.org>

serial: mcf: add devicetree support
    
Add basic support for probing the ColdFire UARTs via a devicetree.

> diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
> index 7cbe43cbe3a0e..01b3ab6e7dba9 100644
> --- a/drivers/tty/serial/mcf.c
> +++ b/drivers/tty/serial/mcf.c
> @@ -582,6 +584,8 @@ static int mcf_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	struct mcf_uart *mp;
>  
> +	if (pdev->id == -1)
> +		pdev->id = mcf_numports;

[Severity: High]
Does modifying pdev->id persistently break deferred probe or unbind/rebind
cycles?

If the device is unbound and rebound, or if probe defers, it will retain
the old ID on the next probe attempt. Since mcf_numports is incremented on
success, this can lead to ID exhaustion over multiple unbind/rebind cycles.

Additionally, should of_alias_get_id(pdev->dev.of_node, "serial") be used
here to respect standard device tree aliases instead of an auto-incrementing
counter?

[Severity: High]
Does this code leave a dangling pointer in the global mcf_ports array if
probe fails later?

If a subsequent call (like devm_platform_get_and_ioremap_resource() or
platform_get_irq()) fails, the devres subsystem will automatically free 'mp'
allocated via devm_kzalloc(), but mcf_ports[pdev->id] is never cleared.

>  	if (pdev->id >= MCF_MAXPORTS)
>  		return -ENODEV;
>  

[ ... ]

> @@ -612,6 +616,8 @@ static int mcf_probe(struct platform_device *pdev)
>  	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MCF_CONSOLE);
>  
>  	uart_add_one_port(&mcf_driver, port);

[Severity: Medium]
Is it safe to ignore the return value of uart_add_one_port() here?

If registration fails (e.g., out of memory or line conflicts), mcf_numports
is still incremented and probe falsely reports success, leaving a partially
initialized state.

> +
> +	mcf_numports++;
>  	return 0;
>  }
>  

[ ... ]

> @@ -629,11 +635,17 @@ static void mcf_remove(struct platform_device *pdev)
>  
>  /****************************************************************************/
>  

[Severity: High]
Will mcf_remove() still unregister all ports system-wide when a single
device is unbound?

It appears that mcf_remove() unconditionally iterates over all MCF_MAXPORTS
and removes every active port, rather than only removing the specific port
associated with the unbound device.

> +static const struct of_device_id mcf_uart_dt_ids[] = {
> +	{ .compatible = "fsl,mcf-uart", },
> +	{ }
> +};
> +

[Severity: Medium]
Does the absence of MODULE_DEVICE_TABLE(of, mcf_uart_dt_ids) prevent module
autoloading when the hardware is present in the device tree?

>  static struct platform_driver mcf_platform_driver = {
>  	.probe		= mcf_probe,
>  	.remove		= mcf_remove,
>  	.driver		= {
>  		.name	= "mcfuart",
> +		.of_match_table = mcf_uart_dt_ids,
>  	},
>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013120831.1046590-1-gerg@linux-m68k.org?part=5

      reply	other threads:[~2026-10-13 12:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 12:06 [PATCH 0/5] serial: mcf: add devicetree support Greg Ungerer
2026-10-13 12:06 ` [PATCH 1/5] serial: mcf: update author email address Greg Ungerer
2026-10-13 12:14   ` sashiko-bot
2026-10-13 12:07 ` [PATCH 2/5] serial: mcf: convert to use proper platform resources Greg Ungerer
2026-10-13 12:24   ` sashiko-bot
2026-10-13 12:07 ` [PATCH 3/5] serial: mcf: dynamically allocate memory Greg Ungerer
2026-10-13 12:38   ` sashiko-bot
2026-10-13 12:07 ` [PATCH 4/5] dt-bindings: serial: create binding for mcf-uart Greg Ungerer
2026-10-13 12:40   ` sashiko-bot
2026-10-13 12:07 ` [PATCH 5/5] serial: mcf: add devicetree support Greg Ungerer
2026-10-13 12:49   ` 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=sashiko-outbox-169741@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gerg@linux-m68k.org \
    --cc=linux-serial@vger.kernel.org \
    --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 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.