diff mbox series

[net] net: hinic: Fix cleanup in create_rxqs/txqs()

Message ID 0cc98faf-a0ed-4565-a55b-0fa2734bc205@stanley.mountain (mailing list archive)
State Accepted
Commit 7203d10e93b6e6e1d19481ef7907de6a9133a467
Delegated to: Netdev Maintainers
Headers show
Series [net] net: hinic: Fix cleanup in create_rxqs/txqs() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 6 this patch: 6
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-13--15-00 (tests: 795)

Commit Message

Dan Carpenter Dec. 13, 2024, 2:28 p.m. UTC
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(+)

Comments

Simon Horman Dec. 16, 2024, 10:33 a.m. UTC | #1
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>
patchwork-bot+netdevbpf@kernel.org Dec. 17, 2024, 2:30 a.m. UTC | #2
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!
diff mbox series

Patch

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;
 }