OSDN Git Service

net: thunderbolt: fix memory leak in tbnet_open()
authorZhengchao Shao <shaozhengchao@huawei.com>
Wed, 7 Dec 2022 01:50:01 +0000 (09:50 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 8 Dec 2022 17:07:37 +0000 (09:07 -0800)
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: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20221207015001.1755826-1-shaozhengchao@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/thunderbolt.c

index a52ee2b..6312f67 100644 (file)
@@ -914,6 +914,7 @@ static int tbnet_open(struct net_device *dev)
                                eof_mask, tbnet_start_poll, net);
        if (!ring) {
                netdev_err(dev, "failed to allocate Rx ring\n");
+               tb_xdomain_release_out_hopid(xd, hopid);
                tb_ring_free(net->tx_ring.ring);
                net->tx_ring.ring = NULL;
                return -ENOMEM;