diff mbox series

[net,v2] net: thunderbolt: fix memory leak in tbnet_open()

Message ID 20221206010646.3552313-1-shaozhengchao@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net,v2] net: thunderbolt: fix memory leak in tbnet_open() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Dec. 6, 2022, 1:06 a.m. UTC
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(+)

Comments

Mika Westerberg Dec. 6, 2022, 6:09 a.m. UTC | #1
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>
Jiri Pirko Dec. 6, 2022, 9:38 a.m. UTC | #2
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
>
shaozhengchao Dec. 7, 2022, 12:53 a.m. UTC | #3
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
>>
diff mbox series

Patch

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;