From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Johan Hovold <johan@kernel.org>
Cc: Bjorn Andersson <andersson@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Guangshuo Li <lgs201920130244@gmail.com>,
linux-remoteproc@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Erin Lo <erin.lo@mediatek.com>
Subject: Re: [PATCH] remoteproc: scp: fix device reference leak on failed lookup
Date: Wed, 8 Jul 2026 11:07:52 -0600 [thread overview]
Message-ID: <ak6D6JX1jP1NxNUh@p14s> (raw)
In-Reply-To: <20260706065614.389412-1-johan@kernel.org>
On Mon, Jul 06, 2026 at 08:56:14AM +0200, Johan Hovold wrote:
> Make sure to drop the reference taken to the SCP device when attempting
> to look up its driver data before the driver has been bound.
>
> Note that holding a reference to a device does not prevent its driver
> data from going away.
>
> Fixes: 63c13d61eafe ("remoteproc/mediatek: add SCP support for mt8183")
> Cc: stable@vger.kernel.org # 5.6
> Cc: Erin Lo <erin.lo@mediatek.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/remoteproc/mtk_scp.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
Applied.
Thanks,
Mathieu
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index 85a74c9ec521..436656bdfa8b 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -36,6 +36,7 @@ struct mtk_scp *scp_get(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct device_node *scp_node;
> struct platform_device *scp_pdev;
> + struct mtk_scp *scp;
>
> scp_node = of_parse_phandle(dev->of_node, "mediatek,scp", 0);
> if (!scp_node) {
> @@ -51,7 +52,13 @@ struct mtk_scp *scp_get(struct platform_device *pdev)
> return NULL;
> }
>
> - return platform_get_drvdata(scp_pdev);
> + scp = platform_get_drvdata(scp_pdev);
> + if (!scp) {
> + put_device(&scp_pdev->dev);
> + return NULL;
> + }
> +
> + return scp;
> }
> EXPORT_SYMBOL_GPL(scp_get);
>
> --
> 2.54.0
>
prev parent reply other threads:[~2026-07-08 17:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 6:56 [PATCH] remoteproc: scp: fix device reference leak on failed lookup Johan Hovold
2026-07-08 17:07 ` Mathieu Poirier [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=ak6D6JX1jP1NxNUh@p14s \
--to=mathieu.poirier@linaro.org \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=erin.lo@mediatek.com \
--cc=johan@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=stable@vger.kernel.org \
/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