From aa19a6a90f7ef24df12eed205663f3cfbb7d8174 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 21 Nov 2023 18:06:03 +0100 Subject: [PATCH] Add missing check for nl_socket_alloc failure This can happen if the memory alloc fails. Patch V2: add goto error Patch V3: return -ENOMEM instead of going to error Change-Id: Iee66caa794d267ac5f8bee584633352893047171 Signed-off-by: Arne Schwabe Acked-by: Antonio Quartulli Message-Id: <20231121170603.886801-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27541.html Signed-off-by: Gert Doering (cherry picked from commit d1c31e428120bb0fc9488c62c1691c92a37d94c3) --- src/openvpn/dco_linux.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b033f8543ea..3c91606b731 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -81,6 +81,12 @@ 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"); + return -ENOMEM; + } + ret = genl_connect(nl_sock); if (ret) {