Re: [Openvpn-devel] [PATCH v2] Add missing check for nl_socket_alloc failure
Hi, On 25/04/2023 12:20, Arne Schwabe wrote: This can happen if the memory alloc fails. Patch V2: add goto error Change-Id: Iee66caa794d267ac5f8bee584633352893047171 Signed-off-by: Arne Schwabe This patch seems to be a duplicate? I also commented the "old v2". Cheers, --- src/openvpn/dco_linux.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 41540c0f8..95fe94848 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -83,6 +83,13 @@ resolve_ovpn_netlink_id(int msglevel) int ret; struct nl_sock *nl_sock = nl_socket_alloc(); +if (!nl_sock) +{ +msg(msglevel, "Allocating net link socket failed"); +ret = -1; +goto err_sock; +} + ret = genl_connect(nl_sock); if (ret) { -- Antonio Quartulli -- Antonio Quartulli ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [PATCH v2] Add missing check for nl_socket_alloc failure
This can happen if the memory alloc fails. Patch V2: add goto error Change-Id: Iee66caa794d267ac5f8bee584633352893047171 Signed-off-by: Arne Schwabe --- src/openvpn/dco_linux.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 41540c0f8..95fe94848 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -83,6 +83,13 @@ resolve_ovpn_netlink_id(int msglevel) int ret; struct nl_sock *nl_sock = nl_socket_alloc(); +if (!nl_sock) +{ +msg(msglevel, "Allocating net link socket failed"); +ret = -1; +goto err_sock; +} + ret = genl_connect(nl_sock); if (ret) { -- 2.37.1 (Apple Git-137.1) ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH v2] Add missing check for nl_socket_alloc failure
On 29/03/2023 14:46, Arne Schwabe wrote: This can happen if the memory alloc fails. Patch V2: add goto error Change-Id: Iee66caa794d267ac5f8bee584633352893047171 Signed-off-by: Arne Schwabe --- src/openvpn/dco_linux.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 41540c0f8..95fe94848 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -83,6 +83,13 @@ resolve_ovpn_netlink_id(int msglevel) int ret; struct nl_sock *nl_sock = nl_socket_alloc(); +if (!nl_sock) +{ +msg(msglevel, "Allocating net link socket failed"); +ret = -1; Please use -ENOMEM here - it is always better to return an actual reason rather than just "failed". +goto err_sock; There is no need to jump to cleanup. You can just return -1 here and save one line. (this is what we do in other functions of this file) Cheers, -- Antonio Quartulli ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [PATCH v2] Add missing check for nl_socket_alloc failure
This can happen if the memory alloc fails. Patch V2: add goto error Change-Id: Iee66caa794d267ac5f8bee584633352893047171 Signed-off-by: Arne Schwabe --- src/openvpn/dco_linux.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 41540c0f8..95fe94848 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -83,6 +83,13 @@ resolve_ovpn_netlink_id(int msglevel) int ret; struct nl_sock *nl_sock = nl_socket_alloc(); +if (!nl_sock) +{ +msg(msglevel, "Allocating net link socket failed"); +ret = -1; +goto err_sock; +} + ret = genl_connect(nl_sock); if (ret) { -- 2.37.1 (Apple Git-137.1) ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel