From adbae9962146896a90546ef2cd61abc938c7c2f7 Mon Sep 17 00:00:00 2001 From: Mark Rustad Date: Fri, 8 Apr 2011 00:24:04 +0000 Subject: [PATCH 15/16] fcoemon: Fix 2 file descriptor leaks Fix 2 file descriptor leaks, one of which can occur repeatedly. Signed-off-by: Mark Rustad Tested-by: Ross Brattain Signed-off-by: Robert Love Signed-off-by: Petr Sabata --- fcoemon.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/fcoemon.c b/fcoemon.c index 5449ae6..f2f3b86 100644 --- a/fcoemon.c +++ b/fcoemon.c @@ -472,6 +472,7 @@ static int fcm_link_init(void) rc = bind(fd, (struct sockaddr *)&l_local, sizeof(l_local)); if (rc == -1) { FCM_LOG_ERR(errno, "bind error"); + close(fd); return rc; } fcm_link_socket = fd; @@ -1255,8 +1256,10 @@ static void fcm_dcbd_retry_timeout(void *arg) static void fcm_dcbd_disconnect(void) { if (fcm_clif != NULL && fcm_clif->cl_local.sun_path[0] != '\0') { - if (fcm_clif->cl_fd >= 0) + if (fcm_clif->cl_fd >= 0) { sa_select_rem_fd(fcm_clif->cl_fd); + close(fcm_clif->cl_fd); + } unlink(fcm_clif->cl_local.sun_path); fcm_clif->cl_local.sun_path[0] = '\0'; fcm_clif->cl_fd = -1; /* mark as disconnected */ -- 1.7.4.4