irqbalance/Don-t-leak-socket-fd-on-connection-error.patch
2019-09-30 10:53:30 -04:00

54 lines
1.6 KiB
Diff

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);
}
--
1.8.3.1