* [PATCH net v2] r8152: add error handling in rtl8152_driver_init
@ 2025-10-10 7:59 yicongsrfy
2025-10-10 13:54 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: yicongsrfy @ 2025-10-10 7:59 UTC (permalink / raw)
To: andrew+netdev, davem, edumazet, oneukum
Cc: horms, kuba, linux-usb, netdev, yicong, stable
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")
Cc: stable@vger.kernel.org
Signed-off-by: Yi Cong <yicong@kylinos.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
v2: replacing return 0 with return ret and adding Cc stable
---
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..8a0c824e9eb4 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 ret;
}
static void __exit rtl8152_driver_exit(void)
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] r8152: add error handling in rtl8152_driver_init
2025-10-10 7:59 [PATCH net v2] r8152: add error handling in rtl8152_driver_init yicongsrfy
@ 2025-10-10 13:54 ` Andrew Lunn
2025-10-11 1:27 ` yicongsrfy
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2025-10-10 13:54 UTC (permalink / raw)
To: yicongsrfy
Cc: andrew+netdev, davem, edumazet, oneukum, horms, kuba, linux-usb,
netdev, yicong, stable
> +
> + ret = usb_register(&rtl8152_driver);
> + if (ret) {
> + usb_deregister_device_driver(&rtl8152_cfgselector_driver);
> + return ret;
> + }
> +
> + return ret;
Now look at this code and think about it.
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] r8152: add error handling in rtl8152_driver_init
2025-10-10 13:54 ` Andrew Lunn
@ 2025-10-11 1:27 ` yicongsrfy
0 siblings, 0 replies; 3+ messages in thread
From: yicongsrfy @ 2025-10-11 1:27 UTC (permalink / raw)
To: andrew
Cc: andrew+netdev, davem, edumazet, horms, kuba, linux-usb, netdev,
oneukum, stable, yicong
On Fri, 10 Oct 2025 15:54:27 +0200, Andrew Lunn <andrew@lunn.ch> wrote:
>
> > +
> > + ret = usb_register(&rtl8152_driver);
> > + if (ret) {
> > + usb_deregister_device_driver(&rtl8152_cfgselector_driver);
> > + return ret;
> > + }
> > +
> > + return ret;
>
> Now look at this code and think about it.
Sorry, these two 'return ret' are indeed redundant.
I will submit a new patch version to fix this.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-11 1:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-10 7:59 [PATCH net v2] r8152: add error handling in rtl8152_driver_init yicongsrfy
2025-10-10 13:54 ` Andrew Lunn
2025-10-11 1:27 ` yicongsrfy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox