From: Haotian Zhang <vulab@iscas.ac.cn>
To: Herve Codina <herve.codina@bootlin.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH] net: wan: framer: pef2256: Fix missing mfd_remove_devices() call
Date: Mon, 3 Nov 2025 19:18:44 +0800 [thread overview]
Message-ID: <20251103111844.271-1-vulab@iscas.ac.cn> (raw)
The driver calls mfd_add_devices() but fails to call mfd_remove_devices()
in error paths after successful MFD device registration and in the remove
function. This leads to resource leaks where MFD child devices are not
properly unregistered.
Add mfd_remove_devices() call in the error path after mfd_add_devices()
succeeds, and add the missing mfd_remove_devices() call in pef2256_remove()
to properly clean up MFD devices.
Fixes: c96e976d9a05 ("net: wan: framer: Add support for the Lantiq PEF2256 framer")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
drivers/net/wan/framer/pef2256/pef2256.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wan/framer/pef2256/pef2256.c b/drivers/net/wan/framer/pef2256/pef2256.c
index 1e4c8e85d598..d43fbf9bb27d 100644
--- a/drivers/net/wan/framer/pef2256/pef2256.c
+++ b/drivers/net/wan/framer/pef2256/pef2256.c
@@ -821,27 +821,34 @@ static int pef2256_probe(struct platform_device *pdev)
ret = pef2256_setup_e1(pef2256);
if (ret)
- return ret;
+ goto err_mfd_remove;
framer_provider = devm_framer_provider_of_register(pef2256->dev,
framer_provider_simple_of_xlate);
- if (IS_ERR(framer_provider))
- return PTR_ERR(framer_provider);
+ if (IS_ERR(framer_provider)) {
+ ret = PTR_ERR(framer_provider);
+ goto err_mfd_remove;
+ }
/* Add audio devices */
ret = pef2256_add_audio_devices(pef2256);
if (ret < 0) {
dev_err(pef2256->dev, "add audio devices failed (%d)\n", ret);
- return ret;
+ goto err_mfd_remove;
}
return 0;
+
+err_mfd_remove:
+ mfd_remove_devices(pef2256->dev);
+ return ret;
}
static void pef2256_remove(struct platform_device *pdev)
{
struct pef2256 *pef2256 = platform_get_drvdata(pdev);
+ mfd_remove_devices(pef2256->dev);
/* Disable interrupts */
pef2256_write8(pef2256, PEF2256_IMR0, 0xff);
pef2256_write8(pef2256, PEF2256_IMR1, 0xff);
--
2.50.1.windows.1
next reply other threads:[~2025-11-03 11:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 11:18 Haotian Zhang [this message]
2025-11-03 11:43 ` [PATCH] net: wan: framer: pef2256: Fix missing mfd_remove_devices() call Herve Codina
2025-11-03 12:37 ` [PATCH v2] net: wan: framer: pef2256: Switch to devm_mfd_add_devices() Haotian Zhang
2025-11-03 12:39 ` Herve Codina
2025-11-05 1:49 ` Jakub Kicinski
2025-11-05 3:47 ` [PATCH v3] " Haotian Zhang
2025-11-05 7:34 ` Herve Codina
2025-11-06 2:10 ` patchwork-bot+netdevbpf
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=20251103111844.271-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herve.codina@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).