Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: hvc: use modern IRQ acquisition API
Date: Fri, 25 Sep 2026 18:59:57 +0000	[thread overview]
Message-ID: <20260925185957.CDD6E1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925185011.61259-1-rosenp@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tty: hvc: permanent probe failure on -EPROBE_DEFER due to state corruption
--

commit 3ec0d2af78ba8c496b4a45223b1fb5f9769284c2
Author: Rosen Penev <rosenp@gmail.com>

serial: hvc: use modern IRQ acquisition API

This patch updates the hvc_opal driver to use platform_get_irq_optional()
for acquiring its interrupt. It adds handling for -EPROBE_DEFER and other
negative error codes returned by the new API.

> diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
> index 402da9e7c5346..ce726b8b5ab00 100644
> --- a/drivers/tty/hvc/hvc_opal.c
> +++ b/drivers/tty/hvc/hvc_opal.c
[ ... ]
> @@ -209,8 +209,10 @@ static int hvc_opal_probe(struct platform_device *dev)
>  		dev->dev.of_node,
>  		boot ? " (boot console)" : "");
>  
> -	irq = irq_of_parse_and_map(dev->dev.of_node, 0);
> -	if (!irq) {
> +	irq = platform_get_irq_optional(dev, 0);
> +	if (irq == -EPROBE_DEFER)
> +		return irq;

[Severity: High]
Can this early return cause a memory leak and permanent probe failure on retry?

Earlier in hvc_opal_probe(), the driver allocates a struct hvc_opal_priv and
saves it in a global array:

drivers/tty/hvc/hvc_opal.c:hvc_opal_probe() {
    ...
    } else if (hvc_opal_privs[termno] == NULL) {
        pv = kzalloc_obj(struct hvc_opal_priv);
        if (!pv)
            return -ENOMEM;
        pv->proto = proto;
        hvc_opal_privs[termno] = pv;
    ...
}

If platform_get_irq_optional() returns -EPROBE_DEFER here, the function
returns immediately without freeing pv or clearing hvc_opal_privs[termno].

When the driver is later re-probed, it will see that hvc_opal_privs[termno]
is no longer NULL and fail with -ENXIO:

drivers/tty/hvc/hvc_opal.c:hvc_opal_probe() {
    ...
    } else {
        pr_err("hvc_opal: Device %pOF has duplicate terminal number #%d\n",
               dev->dev.of_node, termno);
        return -ENXIO;
    }
}

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

      reply	other threads:[~2026-09-25 18:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 18:50 [PATCH] serial: hvc: use modern IRQ acquisition API Rosen Penev
2026-09-25 18:59 ` 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=20260925185957.CDD6E1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --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