All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] net: thunderbolt: fix memory leak in tbnet_open()
@ 2022-12-06  1:06 Zhengchao Shao
  2022-12-06  6:09 ` Mika Westerberg
  2022-12-06  9:38 ` Jiri Pirko
  0 siblings, 2 replies; 4+ messages in thread
From: Zhengchao Shao @ 2022-12-06  1:06 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>
---
v2: move release ida before free tx_ring
---
 drivers/net/thunderbolt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
index a52ee2bf5575..6312f67f260e 100644
--- a/drivers/net/thunderbolt.c
+++ b/drivers/net/thunderbolt.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net: thunderbolt: fix memory leak in tbnet_open()
  2022-12-06  1:06 [PATCH net v2] net: thunderbolt: fix memory leak in tbnet_open() Zhengchao Shao
@ 2022-12-06  6:09 ` Mika Westerberg
  2022-12-06  9:38 ` Jiri Pirko
  1 sibling, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2022-12-06  6:09 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, michael.jamet, YehezkelShB, davem, edumazet, kuba,
	pabeni, weiyongjun1, yuehaibing

On Tue, Dec 06, 2022 at 09:06:46AM +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>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net: thunderbolt: fix memory leak in tbnet_open()
  2022-12-06  1:06 [PATCH net v2] net: thunderbolt: fix memory leak in tbnet_open() Zhengchao Shao
  2022-12-06  6:09 ` Mika Westerberg
@ 2022-12-06  9:38 ` Jiri Pirko
  2022-12-07  0:53   ` shaozhengchao
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2022-12-06  9:38 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, michael.jamet, mika.westerberg, YehezkelShB, davem,
	edumazet, kuba, pabeni, weiyongjun1, yuehaibing

Tue, Dec 06, 2022 at 02:06:46AM CET, shaozhengchao@huawei.com wrote:
>When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida.

You should be imperative to the codebase in your patch descriptions.

The code fix looks okay.

>
>Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection")
>Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>---
>v2: move release ida before free tx_ring
>---
> drivers/net/thunderbolt.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
>index a52ee2bf5575..6312f67f260e 100644
>--- a/drivers/net/thunderbolt.c
>+++ b/drivers/net/thunderbolt.c
>@@ -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;
>-- 
>2.34.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] net: thunderbolt: fix memory leak in tbnet_open()
  2022-12-06  9:38 ` Jiri Pirko
@ 2022-12-07  0:53   ` shaozhengchao
  0 siblings, 0 replies; 4+ messages in thread
From: shaozhengchao @ 2022-12-07  0:53 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, michael.jamet, mika.westerberg, YehezkelShB, davem,
	edumazet, kuba, pabeni, weiyongjun1, yuehaibing



On 2022/12/6 17:38, Jiri Pirko wrote:
> Tue, Dec 06, 2022 at 02:06:46AM CET, shaozhengchao@huawei.com wrote:
>> When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida.
> 
> You should be imperative to the codebase in your patch descriptions.
> 
Thank you for your advice. I will describe more detail later.

> The code fix looks okay.
> 
>>
>> Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>> ---
>> v2: move release ida before free tx_ring
>> ---
>> drivers/net/thunderbolt.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c
>> index a52ee2bf5575..6312f67f260e 100644
>> --- a/drivers/net/thunderbolt.c
>> +++ b/drivers/net/thunderbolt.c
>> @@ -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;
>> -- 
>> 2.34.1
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-07  0:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06  1:06 [PATCH net v2] net: thunderbolt: fix memory leak in tbnet_open() Zhengchao Shao
2022-12-06  6:09 ` Mika Westerberg
2022-12-06  9:38 ` Jiri Pirko
2022-12-07  0:53   ` shaozhengchao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.