Skip to content

Commit

Permalink
Add missing check for nl_socket_alloc failure
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Antonio Quartulli <[email protected]>
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg27541.html
Signed-off-by: Gert Doering <[email protected]>
(cherry picked from commit d1c31e4)
  • Loading branch information
schwabe authored and cron2 committed Dec 2, 2023
1 parent 5def8d9 commit aa19a6a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/openvpn/dco_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit aa19a6a

Please sign in to comment.