From 8743a7a8978270195693441f370cea552f100cae Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Mon, 29 Apr 2019 20:05:38 +0200
Subject: [PATCH] tipc/node: Fix socket fd check in cmd_node_get_addr()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
Upstream Status: iproute2.git commit 436270a45dea2
commit 436270a45dea2fe5dbc4680f9c8e31f07d167f20
Author: Phil Sutter <phil@nwl.cc>
Date: Thu Aug 17 19:09:32 2017 +0200
tipc/node: Fix socket fd check in cmd_node_get_addr()
socket() returns -1 on error, not 0.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
tipc/node.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tipc/node.c b/tipc/node.c
index 201fe1a4df3bd..fe085aec9b4ac 100644
--- a/tipc/node.c
+++ b/tipc/node.c
@@ -109,7 +109,8 @@ static int cmd_node_get_addr(struct nlmsghdr *nlh, const struct cmd *cmd,
socklen_t sz = sizeof(struct sockaddr_tipc);
struct sockaddr_tipc addr;
- if (!(sk = socket(AF_TIPC, SOCK_RDM, 0))) {
+ sk = socket(AF_TIPC, SOCK_RDM, 0);
+ if (sk < 0) {
fprintf(stderr, "opening TIPC socket: %s\n", strerror(errno));
return -1;
}
--
2.20.1