Skip to contentSkip to conversation

Change in openvpn[master]: tun: free gc arena in windows_set_mtu()

Openvpn-devel In review Răzvan Cojocaru (Code Review) via Openvpn-devel 2 participants 8 messages Nov 2 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1793629964000.I80b9969f555d670bc101635318d245d1b2de8ec5@gerrit.openvpn.net

#1 lore raw

Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email

to review the following change.

Change subject: tun: free gc arena in windows_set_mtu()
......................................................................

tun: free gc arena in windows_set_mtu()

The arena used for strerror_win32() was never freed.

Broken since 0213f80e ("Set the correct mtu on windows based systems").

Change-Id I80b9969f555d670bc101635318d245d1b2de8ec5

---
M src/openvpn/tun.c

1 file changed, 1 insertion(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/2092/1

src/openvpn/tun.c +1 -0
index fdd13ae..988cb6e 100644
@@ -5236,6 +5236,7 @@
         msg(M_INFO, "%s MTU set to %d on interface %d using SetIpInterfaceEntry()", family_name,
             mtu, iface_index);
     }
+    gc_free(&gc);
 }
 
 

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I80b9969f555d670bc101635318d245d1b2de8ec5
Gerrit-Change-Number: 2092
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: Arne Schwabe, Răzvan Cojocaru.

Gert Doering has posted comments on this change by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email )

Change subject: tun: free gc arena in windows_set_mtu()
......................................................................

Patch Set 1: Code-Review-1

(1 comment)

File src/openvpn/tun.c:

https://gerrit.openvpn.net/c/openvpn/+/2092/comment/2353ac7d_a0775f7d?usp=email :
PS1, Line 5239: gc_free(&gc);
I would move the gc_new() and gc_free() both inside the case where it is actually used. Most of the time we should not need to print an error, so do not need a GC arena at all.

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I80b9969f555d670bc101635318d245d1b2de8ec5
Gerrit-Change-Number: 2092
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Răzvan Cojocaru <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
Gerrit-Comment-Date: Mon, 02 Nov 2026 14:36:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: Arne Schwabe, Gert Doering, Răzvan Cojocaru.

Hello Arne Schwabe, Gert Doering,

I'd like you to reexamine a change. Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review-1 by Gert Doering

Change subject: tun: free gc arena in windows_set_mtu()
......................................................................

tun: free gc arena in windows_set_mtu()

The arena used for strerror_win32() was never freed. Allocate it only on the error path, where it is used.

Broken since 0213f80e ("Set the correct mtu on windows based systems").

Change-Id I80b9969f555d670bc101635318d245d1b2de8ec5

---
M src/openvpn/tun.c

1 file changed, 2 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/2092/2

src/openvpn/tun.c +2 -1
index fdd13ae..58f4750 100644
@@ -5203,7 +5203,6 @@
 windows_set_mtu(const int iface_index, const short family, const int mtu)
 {
     DWORD err = 0;
-    struct gc_arena gc = gc_new();
     MIB_IPINTERFACE_ROW ipiface;
     InitializeIpInterfaceEntry(&ipiface);
     const char *family_name = (family == AF_INET6) ? "IPv6" : "IPv4";
@@ -5228,8 +5227,10 @@
 
     if (err != NO_ERROR)
     {
+        struct gc_arena gc = gc_new();
         msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]", family_name,
             strerror_win32(err, &gc), err, iface_index);
+        gc_free(&gc);
     }
     else
     {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I80b9969f555d670bc101635318d245d1b2de8ec5
Gerrit-Change-Number: 2092
Gerrit-PatchSet: 2
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Răzvan Cojocaru <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
Gerrit-Attention: Gert Doering <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: Arne Schwabe, Răzvan Cojocaru.

Gert Doering has posted comments on this change by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email )

Change subject: tun: free gc arena in windows_set_mtu()
......................................................................

Patch Set 2: Code-Review+2

(1 comment)

File src/openvpn/tun.c:

https://gerrit.openvpn.net/c/openvpn/+/2092/comment/271ab542_01b45dfc?usp=email :
PS1, Line 5239: gc_free(&gc);

Quoted 1 line

I would move the gc_new() and gc_free() both inside the case where it is actually used. […]

Done

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I80b9969f555d670bc101635318d245d1b2de8ec5
Gerrit-Change-Number: 2092
Gerrit-PatchSet: 2
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Răzvan Cojocaru <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
Gerrit-Comment-Date: Mon, 02 Nov 2026 14:48:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Gert Doering <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#5 lore raw

PATCH v2 1/1 tun: free gc arena in windows_set_mtu()

In reply to a message not in the archive

From: Razvan Cojocaru <[email protected]>

The arena used for strerror_win32() was never freed. Allocate it only on the error path, where it is used.

Broken since 0213f80e ("Set the correct mtu on windows based systems").

Change-Id I80b9969f555d670bc101635318d245d1b2de8ec5

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2092
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2092
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]>

src/openvpn/tun.c +2 -1
index fdd13ae..58f4750 100644
@@ -5203,7 +5203,6 @@
 windows_set_mtu(const int iface_index, const short family, const int mtu)
 {
     DWORD err = 0;
-    struct gc_arena gc = gc_new();
     MIB_IPINTERFACE_ROW ipiface;
     InitializeIpInterfaceEntry(&ipiface);
     const char *family_name = (family == AF_INET6) ? "IPv6" : "IPv4";
@@ -5228,8 +5227,10 @@
 
     if (err != NO_ERROR)
     {
+        struct gc_arena gc = gc_new();
         msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]", family_name,
             strerror_win32(err, &gc), err, iface_index);
+        gc_free(&gc);
     }
     else
     {

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Acked-by on v2 1/1
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: tun: free gc arena in windows_set_mtu()

Minor leak, but still not what we want :-) - and now it's even faster, and more efficient!!

mail-archive.org seems to suggest I have used up my daily quota of patches to send, so linking to Lore.

Your patch has been applied to the master and release/2.7 branch (bugfix).

commit 97933ad9161fac59e4b738b226ad317ff23a3659 (master) commit 55df1450adaa45321fc88e245df0fac6884eced0 (release/2.7)

Author: Razvan Cojocaru
Date:   Mon Nov 2 15:48:38 2026 +0100

tun: free gc arena in windows_set_mtu()

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2092
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

--
kind regards,

Gert Doering

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#7 lore raw
In reply to a message not in the archive

Gert Doering has submitted this change. ( https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email )

Change subject: tun: free gc arena in windows_set_mtu()
......................................................................

tun: free gc arena in windows_set_mtu()

The arena used for strerror_win32() was never freed. Allocate it only on the error path, where it is used.

Broken since 0213f80e ("Set the correct mtu on windows based systems").

Change-Id I80b9969f555d670bc101635318d245d1b2de8ec5

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2092
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

---
M src/openvpn/tun.c

1 file changed, 2 insertions(+), 1 deletion(-)
src/openvpn/tun.c +2 -1
index fdd13ae..58f4750 100644
@@ -5203,7 +5203,6 @@
 windows_set_mtu(const int iface_index, const short family, const int mtu)
 {
     DWORD err = 0;
-    struct gc_arena gc = gc_new();
     MIB_IPINTERFACE_ROW ipiface;
     InitializeIpInterfaceEntry(&ipiface);
     const char *family_name = (family == AF_INET6) ? "IPv6" : "IPv4";
@@ -5228,8 +5227,10 @@
 
     if (err != NO_ERROR)
     {
+        struct gc_arena gc = gc_new();
         msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]", family_name,
             strerror_win32(err, &gc), err, iface_index);
+        gc_free(&gc);
     }
     else
     {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I80b9969f555d670bc101635318d245d1b2de8ec5
Gerrit-Change-Number: 2092
Gerrit-PatchSet: 3
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#8 lore raw
In reply to a message not in the archive

Gert Doering has uploaded a new patch set (#3) to the change originally created by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by Gert Doering

Change subject: tun: free gc arena in windows_set_mtu()
......................................................................

tun: free gc arena in windows_set_mtu()

The arena used for strerror_win32() was never freed. Allocate it only on the error path, where it is used.

Broken since 0213f80e ("Set the correct mtu on windows based systems").

Change-Id I80b9969f555d670bc101635318d245d1b2de8ec5

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2092
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

---
M src/openvpn/tun.c

1 file changed, 2 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/2092/3

src/openvpn/tun.c +2 -1
index fdd13ae..58f4750 100644
@@ -5203,7 +5203,6 @@
 windows_set_mtu(const int iface_index, const short family, const int mtu)
 {
     DWORD err = 0;
-    struct gc_arena gc = gc_new();
     MIB_IPINTERFACE_ROW ipiface;
     InitializeIpInterfaceEntry(&ipiface);
     const char *family_name = (family == AF_INET6) ? "IPv6" : "IPv4";
@@ -5228,8 +5227,10 @@
 
     if (err != NO_ERROR)
     {
+        struct gc_arena gc = gc_new();
         msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]", family_name,
             strerror_win32(err, &gc), err, iface_index);
+        gc_free(&gc);
     }
     else
     {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2092?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I80b9969f555d670bc101635318d245d1b2de8ec5
Gerrit-Change-Number: 2092
Gerrit-PatchSet: 3
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel