* [PATCH] net: net_netdev: Fix error handling in ntb_netdev_init_module()
@ 2022-11-24 7:09 Yuan Can
2022-11-28 11:10 ` patchwork-bot+netdevbpf
2022-11-28 15:38 ` Dave Jiang
0 siblings, 2 replies; 3+ messages in thread
From: Yuan Can @ 2022-11-24 7:09 UTC (permalink / raw)
To: jdmason, dave.jiang, allenbh, davem, edumazet, kuba, pabeni, nab,
gregkh, ntb, netdev
Cc: yuancan
The ntb_netdev_init_module() returns the ntb_transport_register_client()
directly without checking its return value, if
ntb_transport_register_client() failed, the NTB client device is not
unregistered.
Fix by unregister NTB client device when ntb_transport_register_client()
failed.
Fixes: 548c237c0a99 ("net: Add support for NTB virtual ethernet device")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
drivers/net/ntb_netdev.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
index 464d88ca8ab0..a4abea921046 100644
--- a/drivers/net/ntb_netdev.c
+++ b/drivers/net/ntb_netdev.c
@@ -484,7 +484,14 @@ static int __init ntb_netdev_init_module(void)
rc = ntb_transport_register_client_dev(KBUILD_MODNAME);
if (rc)
return rc;
- return ntb_transport_register_client(&ntb_netdev_client);
+
+ rc = ntb_transport_register_client(&ntb_netdev_client);
+ if (rc) {
+ ntb_transport_unregister_client_dev(KBUILD_MODNAME);
+ return rc;
+ }
+
+ return 0;
}
module_init(ntb_netdev_init_module);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: net_netdev: Fix error handling in ntb_netdev_init_module()
2022-11-24 7:09 [PATCH] net: net_netdev: Fix error handling in ntb_netdev_init_module() Yuan Can
@ 2022-11-28 11:10 ` patchwork-bot+netdevbpf
2022-11-28 15:38 ` Dave Jiang
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-28 11:10 UTC (permalink / raw)
To: Yuan Can
Cc: jdmason, dave.jiang, allenbh, davem, edumazet, kuba, pabeni, nab,
gregkh, ntb, netdev
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Thu, 24 Nov 2022 07:09:17 +0000 you wrote:
> The ntb_netdev_init_module() returns the ntb_transport_register_client()
> directly without checking its return value, if
> ntb_transport_register_client() failed, the NTB client device is not
> unregistered.
>
> Fix by unregister NTB client device when ntb_transport_register_client()
> failed.
>
> [...]
Here is the summary with links:
- net: net_netdev: Fix error handling in ntb_netdev_init_module()
https://git.kernel.org/netdev/net/c/b8f79dccd38e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: net_netdev: Fix error handling in ntb_netdev_init_module()
2022-11-24 7:09 [PATCH] net: net_netdev: Fix error handling in ntb_netdev_init_module() Yuan Can
2022-11-28 11:10 ` patchwork-bot+netdevbpf
@ 2022-11-28 15:38 ` Dave Jiang
1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2022-11-28 15:38 UTC (permalink / raw)
To: Yuan Can, jdmason, allenbh, davem, edumazet, kuba, pabeni, nab,
gregkh, ntb, netdev
On 11/24/2022 12:09 AM, Yuan Can wrote:
> The ntb_netdev_init_module() returns the ntb_transport_register_client()
> directly without checking its return value, if
> ntb_transport_register_client() failed, the NTB client device is not
> unregistered.
>
> Fix by unregister NTB client device when ntb_transport_register_client()
> failed.
>
> Fixes: 548c237c0a99 ("net: Add support for NTB virtual ethernet device")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/net/ntb_netdev.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
> index 464d88ca8ab0..a4abea921046 100644
> --- a/drivers/net/ntb_netdev.c
> +++ b/drivers/net/ntb_netdev.c
> @@ -484,7 +484,14 @@ static int __init ntb_netdev_init_module(void)
> rc = ntb_transport_register_client_dev(KBUILD_MODNAME);
> if (rc)
> return rc;
> - return ntb_transport_register_client(&ntb_netdev_client);
> +
> + rc = ntb_transport_register_client(&ntb_netdev_client);
> + if (rc) {
> + ntb_transport_unregister_client_dev(KBUILD_MODNAME);
> + return rc;
> + }
> +
> + return 0;
> }
> module_init(ntb_netdev_init_module);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-28 15:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24 7:09 [PATCH] net: net_netdev: Fix error handling in ntb_netdev_init_module() Yuan Can
2022-11-28 11:10 ` patchwork-bot+netdevbpf
2022-11-28 15:38 ` Dave Jiang
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).