]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: hinic: Fix cleanup in create_rxqs/txqs()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 13 Dec 2024 14:28:11 +0000 (17:28 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 17 Dec 2024 02:26:17 +0000 (18:26 -0800)
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>
Link: https://patch.msgid.link/0cc98faf-a0ed-4565-a55b-0fa2734bc205@stanley.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/huawei/hinic/hinic_main.c

index 890f213da8d18000ccfc27fe5dbccf0fdcde090d..ae1f523d6841b59759920de7f8724c89bb3d8e63 100644 (file)
@@ -172,6 +172,7 @@ err_init_txq:
        hinic_sq_dbgfs_uninit(nic_dev);
 
        devm_kfree(&netdev->dev, nic_dev->txqs);
+       nic_dev->txqs = NULL;
        return err;
 }
 
@@ -268,6 +269,7 @@ err_init_rxq:
        hinic_rq_dbgfs_uninit(nic_dev);
 
        devm_kfree(&netdev->dev, nic_dev->rxqs);
+       nic_dev->rxqs = NULL;
        return err;
 }