netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: usb: r8152: add error handling in rtl8152_driver_init
@ 2025-10-09  7:58 yicongsrfy
  2025-10-09  8:52 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: yicongsrfy @ 2025-10-09  7:58 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, oneukum; +Cc: kuba, linux-usb, netdev, yicong

From: Yi Cong <yicong@kylinos.cn>

rtl8152_driver_init missing error handling.
If cannot register rtl8152_driver, rtl8152_cfgselector_driver
should be deregistered.

Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
Signed-off-by: Yi Cong <yicong@kylinos.cn>
---
 drivers/net/usb/r8152.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 44cba7acfe7d..a64bcb744fad 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -10122,7 +10122,14 @@ static int __init rtl8152_driver_init(void)
 	ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
 	if (ret)
 		return ret;
-	return usb_register(&rtl8152_driver);
+
+	ret = usb_register(&rtl8152_driver);
+	if (ret) {
+		usb_deregister_device_driver(&rtl8152_cfgselector_driver);
+		return ret;
+	}
+
+	return 0;
 }
 
 static void __exit rtl8152_driver_exit(void)
-- 
2.25.1


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

end of thread, other threads:[~2025-10-09 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-09  7:58 [PATCH] net: usb: r8152: add error handling in rtl8152_driver_init yicongsrfy
2025-10-09  8:52 ` Simon Horman
2025-10-09  9:54 ` Greg KH
2025-10-09 12:01 ` Andrew Lunn

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).