Skip to content

Commit 4790675

Browse files
author
David Sommerseth
committed
Check that we get a proper NETLINK connection
Signed-off-by: David Sommerseth <davids@redhat.com>
1 parent c49e4c1 commit 4790675

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python-ethtool/netlink.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ int open_netlink(PyEtherInfo *ethi)
5858
/* No earlier connections exists, establish a new one */
5959
nlconnection = nl_socket_alloc();
6060
if( nlconnection != NULL ) {
61-
nl_connect(nlconnection, NETLINK_ROUTE);
61+
if( nl_connect(nlconnection, NETLINK_ROUTE) < 0 ) {
62+
return 0;
63+
}
6264
/* Force O_CLOEXEC flag on the NETLINK socket */
6365
if( fcntl(nl_socket_get_fd(nlconnection), F_SETFD, FD_CLOEXEC) == -1 ) {
6466
fprintf(stderr,

0 commit comments

Comments
 (0)