* [PATCH net] net: thunderbolt: fix memory leak in tbnet_open()
@ 2022-12-05 11:55 Zhengchao Shao
2022-12-05 13:38 ` Mika Westerberg
0 siblings, 1 reply; 3+ messages in thread
From: Zhengchao Shao @ 2022-12-05 11:55 UTC (permalink / raw)
To: netdev, michael.jamet, mika.westerberg, YehezkelShB, davem,
edumazet, kuba, pabeni
Cc: weiyongjun1, yuehaibing, shaozhengchao
When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida.
Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
drivers/net/thunderbolt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
index a52ee2bf5575..70fd61ce15c6 100644
--- a/drivers/net/thunderbolt.c
+++ b/drivers/net/thunderbolt.c
@@ -916,6 +916,7 @@ static int tbnet_open(struct net_device *dev)
netdev_err(dev, "failed to allocate Rx ring\n");
tb_ring_free(net->tx_ring.ring);
net->tx_ring.ring = NULL;
+ tb_xdomain_release_out_hopid(xd, hopid);
return -ENOMEM;
}
net->rx_ring.ring = ring;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: thunderbolt: fix memory leak in tbnet_open()
2022-12-05 11:55 [PATCH net] net: thunderbolt: fix memory leak in tbnet_open() Zhengchao Shao
@ 2022-12-05 13:38 ` Mika Westerberg
2022-12-06 0:46 ` shaozhengchao
0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2022-12-05 13:38 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, michael.jamet, YehezkelShB, davem, edumazet, kuba,
pabeni, weiyongjun1, yuehaibing
Hi,
On Mon, Dec 05, 2022 at 07:55:59PM +0800, Zhengchao Shao wrote:
> When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida.
>
> Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
> drivers/net/thunderbolt.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
> index a52ee2bf5575..70fd61ce15c6 100644
> --- a/drivers/net/thunderbolt.c
> +++ b/drivers/net/thunderbolt.c
> @@ -916,6 +916,7 @@ static int tbnet_open(struct net_device *dev)
> netdev_err(dev, "failed to allocate Rx ring\n");
> tb_ring_free(net->tx_ring.ring);
> net->tx_ring.ring = NULL;
> + tb_xdomain_release_out_hopid(xd, hopid);
Can you move this before tb_ring_free()? Like this:
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;
Otherwise looks good to me.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: thunderbolt: fix memory leak in tbnet_open()
2022-12-05 13:38 ` Mika Westerberg
@ 2022-12-06 0:46 ` shaozhengchao
0 siblings, 0 replies; 3+ messages in thread
From: shaozhengchao @ 2022-12-06 0:46 UTC (permalink / raw)
To: Mika Westerberg
Cc: netdev, michael.jamet, YehezkelShB, davem, edumazet, kuba,
pabeni, weiyongjun1, yuehaibing
On 2022/12/5 21:38, Mika Westerberg wrote:
> Hi,
>
> On Mon, Dec 05, 2022 at 07:55:59PM +0800, Zhengchao Shao wrote:
>> When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida.
>>
>> Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>> ---
>> drivers/net/thunderbolt.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
>> index a52ee2bf5575..70fd61ce15c6 100644
>> --- a/drivers/net/thunderbolt.c
>> +++ b/drivers/net/thunderbolt.c
>> @@ -916,6 +916,7 @@ static int tbnet_open(struct net_device *dev)
>> netdev_err(dev, "failed to allocate Rx ring\n");
>> tb_ring_free(net->tx_ring.ring);
>> net->tx_ring.ring = NULL;
>> + tb_xdomain_release_out_hopid(xd, hopid);
>
> Can you move this before tb_ring_free()? Like this:
>
> 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;
>
> Otherwise looks good to me.
>
Hi Mika:
Thank you for your advice. I will send V2.
Zhengchao Shao
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-06 0:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 11:55 [PATCH net] net: thunderbolt: fix memory leak in tbnet_open() Zhengchao Shao
2022-12-05 13:38 ` Mika Westerberg
2022-12-06 0:46 ` shaozhengchao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).