irqbalance: fix memory leak in irq hotplug path

fix memory leak in irq hotplug path

Signed-off-by: qinyu <qinyu32@huawei.com>
This commit is contained in:
qinyu 2023-02-13 17:32:10 +08:00
parent 30ae89382c
commit d9a7000e39
4 changed files with 53 additions and 15 deletions

View File

@ -0,0 +1,30 @@
From ac4ba0667ba691985796f92e1a4b1932b03895a0 Mon Sep 17 00:00:00 2001
From: qyu <qinyu32@huawei.com>
Date: Fri, 20 Jan 2023 15:29:45 +0800
Subject: [PATCH] irqbalance: fix memory leak in irq hotplug path
tmp_info.name duplicate a name string in init_irq_class_and_type(),
free() it before return.
Reference:https://github.com/Irqbalance/irqbalance/commit/ac4ba0667ba691985796f92e1a4b1932b03895a0
Conflict: NA
---
classify.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/classify.c b/classify.c
index 4ea4b44..dac813c 100644
--- a/classify.c
+++ b/classify.c
@@ -778,6 +778,8 @@ int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo)
/* secondly, init irq info by parse savedline */
init_irq_class_and_type(savedline, &tmp_info, irq);
add_new_irq(NULL, &tmp_info);
+ free(tmp_info.name);
+
*pinfo = get_irq_info(irq);
}
if (*pinfo == NULL) {
--
2.33.0

View File

@ -32,7 +32,7 @@ index 80d8fee..9f2be54 100644
irqbalance_SOURCES += thermal.c
endif
diff --git a/classify.c b/classify.c
index 4ea4b44..0bbe608 100644
index dac813c..7d7a933 100644
--- a/classify.c
+++ b/classify.c
@@ -627,12 +627,20 @@ static void add_new_irq(char *path, struct irq_info *hint)
@ -58,8 +58,8 @@ index 4ea4b44..0bbe608 100644
if (!new)
log(TO_CONSOLE, LOG_WARNING, "add_new_irq: Failed to add irq %d\n", irq);
@@ -780,6 +788,7 @@ int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo)
add_new_irq(NULL, &tmp_info);
@@ -782,6 +790,7 @@ int proc_irq_hotplug(char *savedline, int irq, struct irq_info **pinfo)
*pinfo = get_irq_info(irq);
}
+

View File

@ -12,19 +12,19 @@ Signed-off-by: He Jingxian <hejingxian@huawei.com>
---
irqbalance.c | 4 +-
irqbalance.h | 1 +
ui/Makefile | 29 ++++
ui/client.c | 435 +++++++++++++++++++++++++++++++++++++++++++++++++
ui/irqbalance_client.h | 111 +++++++++++++
ui/Makefile | 29 +++
ui/client.c | 435 +++++++++++++++++++++++++++++++++++++++++
ui/irqbalance_client.h | 111 +++++++++++
5 files changed, 578 insertions(+), 2 deletions(-)
create mode 100644 ui/Makefile
create mode 100644 ui/client.c
create mode 100644 ui/irqbalance_client.h
diff --git a/irqbalance.c b/irqbalance.c
index 1af23c6..7c79087 100644
index f73fdbb..fd61e3f 100644
--- a/irqbalance.c
+++ b/irqbalance.c
@@ -452,12 +452,12 @@ void get_object_stat(struct topo_obj *object, void *data)
@@ -459,12 +459,12 @@ void get_object_stat(struct topo_obj *object, void *data)
#ifdef HAVE_IRQBALANCEUI
gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attribute__((unused)))
{
@ -40,10 +40,10 @@ index 1af23c6..7c79087 100644
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
diff --git a/irqbalance.h b/irqbalance.h
index b2e5409..842cead 100644
index 2d2c5d3..97cb9d7 100644
--- a/irqbalance.h
+++ b/irqbalance.h
@@ -175,6 +175,7 @@ extern unsigned int log_mask;
@@ -174,6 +174,7 @@ extern unsigned int log_mask;
#define SOCKET_PATH "irqbalance"
#define SOCKET_TMPFS "/run/irqbalance"
#define MAX_CLIENT_NUM 32
@ -53,7 +53,7 @@ index b2e5409..842cead 100644
extern void get_mask_from_bitmap(char *line, void *mask);
diff --git a/ui/Makefile b/ui/Makefile
new file mode 100644
index 0000000..27e0fbf
index 0000000..933b0f0
--- /dev/null
+++ b/ui/Makefile
@@ -0,0 +1,29 @@
@ -88,7 +88,7 @@ index 0000000..27e0fbf
+ -$(RM) $(TARGET)
diff --git a/ui/client.c b/ui/client.c
new file mode 100644
index 0000000..027404b
index 0000000..1dcbcbb
--- /dev/null
+++ b/ui/client.c
@@ -0,0 +1,435 @@
@ -529,7 +529,7 @@ index 0000000..027404b
+
diff --git a/ui/irqbalance_client.h b/ui/irqbalance_client.h
new file mode 100644
index 0000000..8f18b79
index 0000000..88fb926
--- /dev/null
+++ b/ui/irqbalance_client.h
@@ -0,0 +1,111 @@
@ -645,5 +645,5 @@ index 0000000..8f18b79
+void irqbalance_set_pid(int pid);
+#endif
--
1.8.3.1
2.33.0

View File

@ -1,7 +1,7 @@
Summary: A dynamic adaptive IRQ balancing daemon
Name: irqbalance
Version: 1.9.2
Release: 2
Release: 3
Epoch: 3
License: GPLv2
Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz
@ -23,6 +23,8 @@ Requires: numactl-libs
%define _hardened_build 1
Patch6000: backport-fix-memory-leak-in-irq-hotplug-path.patch
Patch9000: feature-aarch64-add-the-regular-to-get-the-correct-i.patch
Patch9001: feature-add-new-user-irq-policy-config-rule.patch
Patch9002: feature-add-the-switch-of-printing-log.patch
@ -118,6 +120,12 @@ fi
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
%changelog
* Mon Feb 13 2023 qinyu <qinyu32@huawei.com> - 3:1.9.2-3
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: fix memory leak in irq hotplug path
* Wed Feb 1 2023 qinyu <qinyu32@huawei.com> - 3:1.9.2-2
- Type:bugfix
- ID:NA