All of lore.kernel.org
 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: [PATCHv2 1/3] EDAC/fsl_ddr: use devm_platform_ioremap_resource()
Date: Fri, 31 Jul 2026 01:32:15 +0000	[thread overview]
Message-ID: <20260731013215.DE5CA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260731012130.1212640-2-rosenp@gmail.com>

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

Pre-existing issues:
- [High] Possible use-after-free in the interrupt handler during module removal / driver unbind.
- [High] Hardware interrupts are enabled before the IRQ handler is successfully registered, risking an unhandled interrupt storm if the IRQ request fails.
--

--- Patch [1]: [PATCHv2 1/3] EDAC/fsl_ddr: use devm_platform_ioremap_resource() ---
commit 6f9b8e9cc4f802944da43deab8c11651f32e407d
Author: Rosen Penev <rosenp@gmail.com>

EDAC/fsl_ddr: use devm_platform_ioremap_resource()

This commit replaces the open-coded of_address_to_resource() and
devm_ioremap() sequences with devm_platform_ioremap_resource(). It
also removes the explicit devres group management as devm is already
used.

> diff --git a/drivers/edac/fsl_ddr_edac.c b/drivers/edac/fsl_ddr_edac.c
> index e4eaec0aa81d5..4236e06d568e9 100644
> --- a/drivers/edac/fsl_ddr_edac.c
> +++ b/drivers/edac/fsl_ddr_edac.c
[ ... ]
> @@ -638,7 +615,6 @@ int fsl_mc_err_probe(struct platform_device *op)
>  		       pdata->irq);
>  	}
>  
> -	devres_remove_group(&op->dev, fsl_mc_err_probe);
>  	edac_dbg(3, "success\n");
>  	pr_info(EDAC_MOD_STR " MC err registered\n");
>  
> @@ -647,7 +623,6 @@ int fsl_mc_err_probe(struct platform_device *op)
>  err2:
>  	edac_mc_del_mc(&op->dev);
>  err:
> -	devres_release_group(&op->dev, fsl_mc_err_probe);
>  	edac_mc_free(mci);

[Severity: High]
This isn't a bug introduced by this patch, but since we are relying on
devm APIs here, is there a risk of a use-after-free during driver unbind?

During module removal, fsl_mc_err_remove() manually frees the mci structure
via edac_mc_free(mci). However, the shared interrupt handler fsl_mc_isr()
is managed by devm_request_irq() and remains active until the driver core
cleans up devm resources strictly after remove() returns.

If another device sharing the same IRQ line triggers an interrupt in this
window, the kernel will execute fsl_mc_isr(), which unconditionally
dereferences the freed mci pointer:

fsl_mc_isr(..., void *dev_id)
{
        struct mem_ctl_info *mci = dev_id;
        struct fsl_mc_pdata *pdata = mci->pvt_info;
        ...
}

Should the IRQ be explicitly freed in remove(), or registered with a non-devm
API to ensure the handler is unregistered before mci is freed?

[Severity: High]
This is also a pre-existing issue, but does this error path leave the hardware
interrupt enabled if devm_request_irq() fails?

Earlier in fsl_mc_err_probe(), the hardware interrupt is explicitly enabled:

        ddr_out32(pdata, FSL_MC_ERR_INT_EN, DDR_EIE_MBEE | DDR_EIE_SBEE);

If devm_request_irq() fails (for example, due to -EPROBE_DEFER or resource
constraints), the failure path jumps here to err2, which does not disable
the hardware interrupt. If a memory error occurs and the controller asserts
the IRQ line, the lack of a registered handler might cause an unhandled
interrupt storm.

Should the error path disable the interrupt before returning?

>  	return res;
>  }

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

  reply	other threads:[~2026-07-31  1:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  1:21 [PATCHv2 0/3] EDAC/fsl_ddr: some cleanups Rosen Penev
2026-07-31  1:21 ` [PATCHv2 1/3] EDAC/fsl_ddr: use devm_platform_ioremap_resource() Rosen Penev
2026-07-31  1:32   ` sashiko-bot [this message]
2026-07-31  1:21 ` [PATCHv2 2/3] EDAC/fsl_ddr: use non devm for request_irq() Rosen Penev
2026-07-31  1:29   ` sashiko-bot
2026-07-31  1:21 ` [PATCHv2 3/3] EDAC/fsl_ddr: restore MC error registers on probe failure Rosen Penev

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=20260731013215.DE5CA1F000E9@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 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.