Skip to content

Commit 8979f42

Browse files
zhengchaoshaodavem330
authored andcommitted
net: liquidio: release resources when liquidio driver open failed
When liquidio driver open failed, it doesn't release resources. Compile tested only. Fixes: 5b07aee ("liquidio: MSIX support for CN23XX") Fixes: dbc97bf ("net: liquidio: Add missing null pointer checks") Signed-off-by: Zhengchao Shao <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9cbd48d commit 8979f42

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,13 +1794,10 @@ static int liquidio_open(struct net_device *netdev)
17941794

17951795
ifstate_set(lio, LIO_IFSTATE_RUNNING);
17961796

1797-
if (OCTEON_CN23XX_PF(oct)) {
1798-
if (!oct->msix_on)
1799-
if (setup_tx_poll_fn(netdev))
1800-
return -1;
1801-
} else {
1802-
if (setup_tx_poll_fn(netdev))
1803-
return -1;
1797+
if (!OCTEON_CN23XX_PF(oct) || (OCTEON_CN23XX_PF(oct) && !oct->msix_on)) {
1798+
ret = setup_tx_poll_fn(netdev);
1799+
if (ret)
1800+
goto err_poll;
18041801
}
18051802

18061803
netif_tx_start_all_queues(netdev);
@@ -1813,7 +1810,7 @@ static int liquidio_open(struct net_device *netdev)
18131810
/* tell Octeon to start forwarding packets to host */
18141811
ret = send_rx_ctrl_cmd(lio, 1);
18151812
if (ret)
1816-
return ret;
1813+
goto err_rx_ctrl;
18171814

18181815
/* start periodical statistics fetch */
18191816
INIT_DELAYED_WORK(&lio->stats_wk.work, lio_fetch_stats);
@@ -1824,6 +1821,27 @@ static int liquidio_open(struct net_device *netdev)
18241821
dev_info(&oct->pci_dev->dev, "%s interface is opened\n",
18251822
netdev->name);
18261823

1824+
return 0;
1825+
1826+
err_rx_ctrl:
1827+
if (!OCTEON_CN23XX_PF(oct) || (OCTEON_CN23XX_PF(oct) && !oct->msix_on))
1828+
cleanup_tx_poll_fn(netdev);
1829+
err_poll:
1830+
if (lio->ptp_clock) {
1831+
ptp_clock_unregister(lio->ptp_clock);
1832+
lio->ptp_clock = NULL;
1833+
}
1834+
1835+
if (oct->props[lio->ifidx].napi_enabled == 1) {
1836+
list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list)
1837+
napi_disable(napi);
1838+
1839+
oct->props[lio->ifidx].napi_enabled = 0;
1840+
1841+
if (OCTEON_CN23XX_PF(oct))
1842+
oct->droq[0]->ops.poll_mode = 0;
1843+
}
1844+
18271845
return ret;
18281846
}
18291847

0 commit comments

Comments
 (0)