mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ieee802154: fakelb: release platform device if driver registration fails
@ 2026-11-03 10:28 Wentao Liang
  2026-11-03 10:33 ` netdev-bot+sinfo
  2026-11-16 14:59 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03 10:28 UTC (permalink / raw)
  To: Alexander Aring, Stefan Schmidt, Miquel Raynal, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: linux-wpan, netdev, linux-kernel, Wentao Liang, stable

fakelb_init_module() registers a platform device and then registers the
platform driver, returning the result of the latter directly. If driver
registration fails, module initialization fails and the module exit
function is never run, so the platform device is never unregistered and
leaks.

Check the result of platform_driver_register() and unregister the device
on failure. Also check the device registration result, which can be an
ERR_PTR, before using the stored pointer.

Fixes: e1e49b641387 ("drivers/ieee802154: IEEE 802.15.4 loopback driver")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/ieee802154/fakelb.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
index e11d8eda85ea..35863c3aff44 100644
--- a/drivers/net/ieee802154/fakelb.c
+++ b/drivers/net/ieee802154/fakelb.c
@@ -243,12 +243,20 @@ static struct platform_driver ieee802154fake_driver = {
 
 static __init int fakelb_init_module(void)
 {
+	int rc;
+
 	ieee802154fake_dev = platform_device_register_simple(
 			     "ieee802154fakelb", -1, NULL, 0);
+	if (IS_ERR(ieee802154fake_dev))
+		return PTR_ERR(ieee802154fake_dev);
 
 	pr_warn("fakelb driver is marked as deprecated, please use mac802154_hwsim!\n");
 
-	return platform_driver_register(&ieee802154fake_driver);
+	rc = platform_driver_register(&ieee802154fake_driver);
+	if (rc)
+		platform_device_unregister(ieee802154fake_dev);
+
+	return rc;
 }
 
 static __exit void fake_remove_module(void)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ieee802154: fakelb: release platform device if driver registration fails
  2026-11-03 10:28 [PATCH] ieee802154: fakelb: release platform device if driver registration fails Wentao Liang
@ 2026-11-03 10:33 ` netdev-bot+sinfo
  2026-11-16 14:59 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-03 10:33 UTC (permalink / raw)
  To: Wentao Liang
  Cc: Alexander Aring, Stefan Schmidt, Miquel Raynal, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wpan, netdev, linux-kernel, stable

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by code inspection). If it was triggered please include
   the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ieee802154: fakelb: release platform device if driver registration fails
  2026-11-03 10:28 [PATCH] ieee802154: fakelb: release platform device if driver registration fails Wentao Liang
  2026-11-03 10:33 ` netdev-bot+sinfo
@ 2026-11-16 14:59 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2026-11-16 14:59 UTC (permalink / raw)
  To: Wentao Liang
  Cc: Alexander Aring, Stefan Schmidt, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-wpan, netdev,
	linux-kernel, stable

On 03/11/2026 at 10:28:54 GMT, Wentao Liang <vulab@iscas.ac.cn> wrote:

> fakelb_init_module() registers a platform device and then registers the
> platform driver, returning the result of the latter directly. If driver
> registration fails, module initialization fails and the module exit
> function is never run, so the platform device is never unregistered and
> leaks.
>
> Check the result of platform_driver_register() and unregister the device
> on failure. Also check the device registration result, which can be an
> ERR_PTR, before using the stored pointer.
>
> Fixes: e1e49b641387 ("drivers/ieee802154: IEEE 802.15.4 loopback driver")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

I don't think it is super useful, but it's not wrong either.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:28 [PATCH] ieee802154: fakelb: release platform device if driver registration fails Wentao Liang
2026-11-03 10:33 ` netdev-bot+sinfo
2026-11-16 14:59 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®