* [PATCH net] net: hinic: Fix cleanup in create_rxqs/txqs()
@ 2024-12-13 14:28 Dan Carpenter
2024-12-16 10:33 ` Simon Horman
2024-12-17 2:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-12-13 14:28 UTC (permalink / raw)
To: Aviad Krawczyk
Cc: Cai Huoqing, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Zhao Chen, netdev, linux-kernel,
kernel-janitors
There is a check for NULL at the start of create_txqs() and
create_rxqs() which tess if "nic_dev->txqs" is non-NULL. The
intention is that if the device is already open and the queues
are already created then we don't create them a second time.
However, the bug is that if we have an error in the create_txqs()
then the pointer doesn't get set back to NULL. The NULL check
at the start of the function will say that it's already open when
it's not and the device can't be used.
Set ->txqs back to NULL on cleanup on error.
Fixes: c3e79baf1b03 ("net-next/hinic: Add logical Txq and Rxq")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/net/ethernet/huawei/hinic/hinic_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
index 890f213da8d1..ae1f523d6841 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
@@ -172,6 +172,7 @@ static int create_txqs(struct hinic_dev *nic_dev)
hinic_sq_dbgfs_uninit(nic_dev);
devm_kfree(&netdev->dev, nic_dev->txqs);
+ nic_dev->txqs = NULL;
return err;
}
@@ -268,6 +269,7 @@ static int create_rxqs(struct hinic_dev *nic_dev)
hinic_rq_dbgfs_uninit(nic_dev);
devm_kfree(&netdev->dev, nic_dev->rxqs);
+ nic_dev->rxqs = NULL;
return err;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: hinic: Fix cleanup in create_rxqs/txqs()
2024-12-13 14:28 [PATCH net] net: hinic: Fix cleanup in create_rxqs/txqs() Dan Carpenter
@ 2024-12-16 10:33 ` Simon Horman
2024-12-17 2:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-12-16 10:33 UTC (permalink / raw)
To: Dan Carpenter
Cc: Aviad Krawczyk, Cai Huoqing, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Zhao Chen, netdev,
linux-kernel, kernel-janitors
On Fri, Dec 13, 2024 at 05:28:11PM +0300, Dan Carpenter wrote:
> There is a check for NULL at the start of create_txqs() and
> create_rxqs() which tess if "nic_dev->txqs" is non-NULL. The
> intention is that if the device is already open and the queues
> are already created then we don't create them a second time.
>
> However, the bug is that if we have an error in the create_txqs()
> then the pointer doesn't get set back to NULL. The NULL check
> at the start of the function will say that it's already open when
> it's not and the device can't be used.
>
> Set ->txqs back to NULL on cleanup on error.
>
> Fixes: c3e79baf1b03 ("net-next/hinic: Add logical Txq and Rxq")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: hinic: Fix cleanup in create_rxqs/txqs()
2024-12-13 14:28 [PATCH net] net: hinic: Fix cleanup in create_rxqs/txqs() Dan Carpenter
2024-12-16 10:33 ` Simon Horman
@ 2024-12-17 2:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-17 2:30 UTC (permalink / raw)
To: Dan Carpenter
Cc: aviad.krawczyk, cai.huoqing, andrew+netdev, davem, edumazet, kuba,
pabeni, zhaochen6, netdev, linux-kernel, kernel-janitors
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 13 Dec 2024 17:28:11 +0300 you wrote:
> There is a check for NULL at the start of create_txqs() and
> create_rxqs() which tess if "nic_dev->txqs" is non-NULL. The
> intention is that if the device is already open and the queues
> are already created then we don't create them a second time.
>
> However, the bug is that if we have an error in the create_txqs()
> then the pointer doesn't get set back to NULL. The NULL check
> at the start of the function will say that it's already open when
> it's not and the device can't be used.
>
> [...]
Here is the summary with links:
- [net] net: hinic: Fix cleanup in create_rxqs/txqs()
https://git.kernel.org/netdev/net/c/7203d10e93b6
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
end of thread, other threads:[~2024-12-17 2:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13 14:28 [PATCH net] net: hinic: Fix cleanup in create_rxqs/txqs() Dan Carpenter
2024-12-16 10:33 ` Simon Horman
2024-12-17 2: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).