From: Johan Hovold <johan@kernel.org>
To: Yong Wu <yong.wu@mediatek.com>, Krzysztof Kozlowski <krzk@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 3/3] memory: mtk-smi: clean up device link creation
Date: Fri, 21 Nov 2025 17:46:24 +0100 [thread overview]
Message-ID: <20251121164624.13685-4-johan@kernel.org> (raw)
In-Reply-To: <20251121164624.13685-1-johan@kernel.org>
Clean up device link creation by bailing out early in case the SMI
platform device lookup fails.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/memory/mtk-smi.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index 3609bfd3c64b..aaeba8ab211e 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -595,25 +595,28 @@ static int mtk_smi_device_link_common(struct device *dev, struct device **com_de
smi_com_pdev = of_find_device_by_node(smi_com_node);
of_node_put(smi_com_node);
- if (smi_com_pdev) {
- /* smi common is the supplier, Make sure it is ready before */
- if (!platform_get_drvdata(smi_com_pdev)) {
- put_device(&smi_com_pdev->dev);
- return -EPROBE_DEFER;
- }
- smi_com_dev = &smi_com_pdev->dev;
- link = device_link_add(dev, smi_com_dev,
- DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
- if (!link) {
- dev_err(dev, "Unable to link smi-common dev\n");
- put_device(&smi_com_pdev->dev);
- return -ENODEV;
- }
- *com_dev = smi_com_dev;
- } else {
+ if (!smi_com_pdev) {
dev_err(dev, "Failed to get the smi_common device\n");
return -EINVAL;
}
+
+ /* smi common is the supplier, Make sure it is ready before */
+ if (!platform_get_drvdata(smi_com_pdev)) {
+ put_device(&smi_com_pdev->dev);
+ return -EPROBE_DEFER;
+ }
+
+ smi_com_dev = &smi_com_pdev->dev;
+ link = device_link_add(dev, smi_com_dev,
+ DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
+ if (!link) {
+ dev_err(dev, "Unable to link smi-common dev\n");
+ put_device(&smi_com_pdev->dev);
+ return -ENODEV;
+ }
+
+ *com_dev = smi_com_dev;
+
return 0;
}
--
2.51.2
next prev parent reply other threads:[~2025-11-21 16:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 16:46 [PATCH 0/3] memory: mtk-smi: fix device leaks on probe Johan Hovold
2025-11-21 16:46 ` [PATCH 1/3] memory: mtk-smi: fix device leaks on common probe Johan Hovold
2025-12-16 7:16 ` Krzysztof Kozlowski
2025-11-21 16:46 ` [PATCH 2/3] memory: mtk-smi: fix device leak on larb probe Johan Hovold
2025-11-21 16:46 ` Johan Hovold [this message]
2025-12-16 7:22 ` [PATCH 0/3] memory: mtk-smi: fix device leaks on probe Krzysztof Kozlowski
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=20251121164624.13685-4-johan@kernel.org \
--to=johan@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=yong.wu@mediatek.com \
/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.