2019-09-30 10:53:30 -04:00
|
|
|
From f2623176c2997e7803d485084fa5150556caddcf Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Kairui Song <kasong@redhat.com>
|
|
|
|
|
Date: Mon, 5 Nov 2018 17:18:49 +0800
|
|
|
|
|
Subject: [PATCH 102/112] Don't leak socket fd on connection error
|
|
|
|
|
|
|
|
|
|
Signed-off-by: Kairui Song <kasong@redhat.com>
|
|
|
|
|
---
|
|
|
|
|
irqbalance.c | 7 ++++---
|
|
|
|
|
ui/irqbalance-ui.c | 1 +
|
|
|
|
|
2 files changed, 5 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/irqbalance.c b/irqbalance.c
|
|
|
|
|
index 0946603..364ca72 100644
|
|
|
|
|
--- a/irqbalance.c
|
|
|
|
|
+++ b/irqbalance.c
|
|
|
|
|
@@ -376,7 +376,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
|
|
|
|
|
}
|
|
|
|
|
if ((recv_size = recvmsg(sock, &msg, 0)) < 0) {
|
|
|
|
|
log(TO_ALL, LOG_WARNING, "Error while receiving data.\n");
|
|
|
|
|
- goto out;
|
|
|
|
|
+ goto out_close;
|
|
|
|
|
}
|
|
|
|
|
cmsg = CMSG_FIRSTHDR(&msg);
|
|
|
|
|
if ((cmsg->cmsg_level == SOL_SOCKET) &&
|
|
|
|
|
@@ -388,7 +388,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
|
|
|
|
|
}
|
|
|
|
|
if (!valid_user) {
|
|
|
|
|
log(TO_ALL, LOG_INFO, "Permission denied for user to connect to socket.\n");
|
|
|
|
|
- goto out;
|
|
|
|
|
+ goto out_close;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strncmp(buff, "stats", strlen("stats"))) {
|
|
|
|
|
@@ -421,7 +421,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
|
|
|
|
|
need_rescan = 1;
|
|
|
|
|
if (!strncmp(irq_string, "NONE", strlen("NONE"))) {
|
|
|
|
|
free(irq_string);
|
|
|
|
|
- goto out;
|
|
|
|
|
+ goto out_close;
|
|
|
|
|
}
|
|
|
|
|
int irq = strtoul(irq_string, &end, 10);
|
|
|
|
|
do {
|
|
|
|
|
@@ -457,6 +457,7 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
|
|
|
|
|
free(setup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+out_close:
|
|
|
|
|
close(sock);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 09:48:32 +08:00
|
|
|
diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c
|
|
|
|
|
index 5a76ddf..005eea4 100644
|
|
|
|
|
--- a/ui/irqbalance-ui.c
|
|
|
|
|
+++ b/ui/irqbalance-ui.c
|
|
|
|
|
@@ -66,6 +66,7 @@ int init_connection()
|
|
|
|
|
memset(&addr, 0, sizeof(struct sockaddr_un));
|
|
|
|
|
addr.sun_family = AF_UNIX;
|
|
|
|
|
if (connect(socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
|
|
|
|
+ close(socket_fd);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-30 10:53:30 -04:00
|
|
|
--
|
|
|
|
|
1.8.3.1
|
|
|
|
|
|