Commit ed14e590 authored by Zhengchao Shao's avatar Zhengchao Shao Committed by Jakub Kicinski

net: thunderbolt: fix memory leak in tbnet_open()

When tb_ring_alloc_rx() failed in tbnet_open(), ida that allocated in
tb_xdomain_alloc_out_hopid() is not released. Add
tb_xdomain_release_out_hopid() to the error path to release ida.

Fixes: 180b0689 ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection")
Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20221207015001.1755826-1-shaozhengchao@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 803e8486
...@@ -914,6 +914,7 @@ static int tbnet_open(struct net_device *dev) ...@@ -914,6 +914,7 @@ static int tbnet_open(struct net_device *dev)
eof_mask, tbnet_start_poll, net); eof_mask, tbnet_start_poll, net);
if (!ring) { if (!ring) {
netdev_err(dev, "failed to allocate Rx ring\n"); netdev_err(dev, "failed to allocate Rx ring\n");
tb_xdomain_release_out_hopid(xd, hopid);
tb_ring_free(net->tx_ring.ring); tb_ring_free(net->tx_ring.ring);
net->tx_ring.ring = NULL; net->tx_ring.ring = NULL;
return -ENOMEM; return -ENOMEM;
......
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