* [PATCH] net: cxgb3: Fix an error code when probing the driver
@ 2022-03-05 14:24 Zheyu Ma
2022-03-05 15:40 ` Andrew Lunn
2022-03-06 5:56 ` [PATCH v2] " Zheyu Ma
0 siblings, 2 replies; 5+ messages in thread
From: Zheyu Ma @ 2022-03-05 14:24 UTC (permalink / raw)
To: rajur, davem, kuba; +Cc: netdev, linux-kernel, Zheyu Ma
During the process of driver probing, probe function should return < 0
for failure, otherwise kernel will treat value >= 0 as success.
Therefore, the driver should set 'err' to -EINVAL when
'adapter->registered_device_map' is NULL. Otherwise kernel will assume
that the driver has been successfully probed and will cause unexpected
errors.
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index bfffcaeee624..662af61fc723 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -3346,6 +3346,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
if (!adapter->registered_device_map) {
dev_err(&pdev->dev, "could not register any net devices\n");
+ err = -EINVAL;
goto out_free_dev;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: cxgb3: Fix an error code when probing the driver
2022-03-05 14:24 [PATCH] net: cxgb3: Fix an error code when probing the driver Zheyu Ma
@ 2022-03-05 15:40 ` Andrew Lunn
2022-03-06 5:56 ` [PATCH v2] " Zheyu Ma
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2022-03-05 15:40 UTC (permalink / raw)
To: Zheyu Ma; +Cc: rajur, davem, kuba, netdev, linux-kernel
On Sat, Mar 05, 2022 at 02:24:44PM +0000, Zheyu Ma wrote:
> During the process of driver probing, probe function should return < 0
> for failure, otherwise kernel will treat value >= 0 as success.
>
> Therefore, the driver should set 'err' to -EINVAL when
> 'adapter->registered_device_map' is NULL. Otherwise kernel will assume
> that the driver has been successfully probed and will cause unexpected
> errors.
>
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
> drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
> index bfffcaeee624..662af61fc723 100644
> --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
> +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
> @@ -3346,6 +3346,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> }
> if (!adapter->registered_device_map) {
> dev_err(&pdev->dev, "could not register any net devices\n");
> + err = -EINVAL;
ENODEV would be better.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] net: cxgb3: Fix an error code when probing the driver
2022-03-05 14:24 [PATCH] net: cxgb3: Fix an error code when probing the driver Zheyu Ma
2022-03-05 15:40 ` Andrew Lunn
@ 2022-03-06 5:56 ` Zheyu Ma
2022-03-06 15:15 ` Andrew Lunn
2022-03-08 6:30 ` patchwork-bot+netdevbpf
1 sibling, 2 replies; 5+ messages in thread
From: Zheyu Ma @ 2022-03-06 5:56 UTC (permalink / raw)
To: andrew, rajur, davem, kuba; +Cc: netdev, linux-kernel, Zheyu Ma
During the process of driver probing, probe function should return < 0
for failure, otherwise kernel will treat value >= 0 as success.
Therefore, the driver should set 'err' to -ENODEV when
'adapter->registered_device_map' is NULL. Otherwise kernel will assume
that the driver has been successfully probed and will cause unexpected
errors.
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
Changes in v2:
- Change the error code
---
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index bfffcaeee624..0d3325cf2107 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -3346,6 +3346,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
if (!adapter->registered_device_map) {
dev_err(&pdev->dev, "could not register any net devices\n");
+ err = -ENODEV;
goto out_free_dev;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] net: cxgb3: Fix an error code when probing the driver
2022-03-06 5:56 ` [PATCH v2] " Zheyu Ma
@ 2022-03-06 15:15 ` Andrew Lunn
2022-03-08 6:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2022-03-06 15:15 UTC (permalink / raw)
To: Zheyu Ma; +Cc: rajur, davem, kuba, netdev, linux-kernel
On Sun, Mar 06, 2022 at 05:56:32AM +0000, Zheyu Ma wrote:
> During the process of driver probing, probe function should return < 0
> for failure, otherwise kernel will treat value >= 0 as success.
>
> Therefore, the driver should set 'err' to -ENODEV when
> 'adapter->registered_device_map' is NULL. Otherwise kernel will assume
> that the driver has been successfully probed and will cause unexpected
> errors.
>
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] net: cxgb3: Fix an error code when probing the driver
2022-03-06 5:56 ` [PATCH v2] " Zheyu Ma
2022-03-06 15:15 ` Andrew Lunn
@ 2022-03-08 6:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-08 6:30 UTC (permalink / raw)
To: Zheyu Ma; +Cc: andrew, rajur, davem, kuba, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 6 Mar 2022 05:56:32 +0000 you wrote:
> During the process of driver probing, probe function should return < 0
> for failure, otherwise kernel will treat value >= 0 as success.
>
> Therefore, the driver should set 'err' to -ENODEV when
> 'adapter->registered_device_map' is NULL. Otherwise kernel will assume
> that the driver has been successfully probed and will cause unexpected
> errors.
>
> [...]
Here is the summary with links:
- [v2] net: cxgb3: Fix an error code when probing the driver
https://git.kernel.org/netdev/net-next/c/69adcb988a06
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] 5+ messages in thread
end of thread, other threads:[~2022-03-08 6:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-05 14:24 [PATCH] net: cxgb3: Fix an error code when probing the driver Zheyu Ma
2022-03-05 15:40 ` Andrew Lunn
2022-03-06 5:56 ` [PATCH v2] " Zheyu Ma
2022-03-06 15:15 ` Andrew Lunn
2022-03-08 6:30 ` patchwork-bot+netdevbpf
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).