Commit 5821504f authored by Roger Quadros's avatar Roger Quadros Committed by Jakub Kicinski

net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open()

Ensure pm_runtime_put() is issued in error path.
Reported-by: default avatarJakub Kicinski <kuba@kernel.org>
Fixes: 93a76530 ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Signed-off-by: default avatarRoger Quadros <rogerq@kernel.org>
Reviewed-by: default avatarSaeed Mahameed <saeed@kernel.org>
Link: https://lore.kernel.org/r/20221208105534.63709-1-rogerq@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent fba119ce
...@@ -573,20 +573,21 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) ...@@ -573,20 +573,21 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
reg = cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_SOFT_RESET); reg = cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_SOFT_RESET);
if (reg) { if (reg) {
dev_err(common->dev, "soft RESET didn't complete\n"); dev_err(common->dev, "soft RESET didn't complete\n");
return -ETIMEDOUT; ret = -ETIMEDOUT;
goto runtime_put;
} }
/* Notify the stack of the actual queue counts. */ /* Notify the stack of the actual queue counts. */
ret = netif_set_real_num_tx_queues(ndev, common->tx_ch_num); ret = netif_set_real_num_tx_queues(ndev, common->tx_ch_num);
if (ret) { if (ret) {
dev_err(common->dev, "cannot set real number of tx queues\n"); dev_err(common->dev, "cannot set real number of tx queues\n");
return ret; goto runtime_put;
} }
ret = netif_set_real_num_rx_queues(ndev, AM65_CPSW_MAX_RX_QUEUES); ret = netif_set_real_num_rx_queues(ndev, AM65_CPSW_MAX_RX_QUEUES);
if (ret) { if (ret) {
dev_err(common->dev, "cannot set real number of rx queues\n"); dev_err(common->dev, "cannot set real number of rx queues\n");
return ret; goto runtime_put;
} }
for (i = 0; i < common->tx_ch_num; i++) for (i = 0; i < common->tx_ch_num; i++)
...@@ -594,7 +595,7 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) ...@@ -594,7 +595,7 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
ret = am65_cpsw_nuss_common_open(common); ret = am65_cpsw_nuss_common_open(common);
if (ret) if (ret)
return ret; goto runtime_put;
common->usage_count++; common->usage_count++;
...@@ -622,6 +623,10 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) ...@@ -622,6 +623,10 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
error_cleanup: error_cleanup:
am65_cpsw_nuss_ndo_slave_stop(ndev); am65_cpsw_nuss_ndo_slave_stop(ndev);
return ret; return ret;
runtime_put:
pm_runtime_put(common->dev);
return ret;
} }
static void am65_cpsw_nuss_rx_cleanup(void *data, dma_addr_t desc_dma) static void am65_cpsw_nuss_rx_cleanup(void *data, dma_addr_t desc_dma)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment