diff mbox

[opensm] osm_console_io.c: Handle return value of function setsockopt

Message ID 53610A28.7040201@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock April 30, 2014, 2:35 p.m. UTC
From: Tomer Cohen <tomerco@mellanox.com>

Found by Coverity

Signed-off-by: Tomer Cohen <tomerco@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_console_io.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_console_io.c b/opensm/osm_console_io.c
index dfc903f..2426b84 100644
--- a/opensm/osm_console_io.c
+++ b/opensm/osm_console_io.c
@@ -208,8 +208,15 @@  int osm_console_init(osm_subn_opt_t * opt, osm_console_t * p_oct, osm_log_t * p_
 				strerror(errno));
 			return -1;
 		}
-		setsockopt(p_oct->socket, SOL_SOCKET, SO_REUSEADDR,
-			   &optval, sizeof(optval));
+
+		if (setsockopt(p_oct->socket, SOL_SOCKET, SO_REUSEADDR,
+			       &optval, sizeof(optval))) {
+			OSM_LOG(p_log, OSM_LOG_ERROR,
+		                "ERR 4B06: Failed to set socket option: %s\n",
+		                strerror(errno));
+		        return -1;
+		}
+
 		sin.sin_family = AF_INET;
 		sin.sin_port = htons(opt->console_port);
 #ifdef ENABLE_OSM_CONSOLE_SOCKET