|
|
120141 |
From c8d1fff0f16ad906cca153a22faac11516ccc0dd Mon Sep 17 00:00:00 2001
|
|
|
120141 |
From: Liu Chao <liuchao173@huawei.com>
|
|
|
120141 |
Date: Mon, 18 Jul 2022 16:54:53 +0800
|
|
|
120141 |
Subject: [PATCH] irqbalance-ui: skip ',' in parse_setup to avoid coredump
|
|
|
120141 |
|
|
|
120141 |
When processing the ',' in hex_to_bitmap, it returns '0000\ 0' directly.
|
|
|
120141 |
The return value will be freed in parse_setup, but it is not requested
|
|
|
120141 |
through malloc.
|
|
|
120141 |
|
|
|
120141 |
Fixes: 85d37098a551 ("Fix several memleak problems found by covscan")
|
|
|
120141 |
|
|
|
120141 |
And it treat ',' as "0000", which cause irqbalance-ui will display wrong
|
|
|
120141 |
Banned CPU numbers.
|
|
|
120141 |
|
|
|
120141 |
For example:
|
|
|
120141 |
# IRQBALANCE_BANNED_CPUS="00000002,00000000,00000000" ./irqbalance
|
|
|
120141 |
or
|
|
|
120141 |
# IRQBALANCE_BANNED_CPULIST="65" ./irqbalance
|
|
|
120141 |
|
|
|
120141 |
# ./irqbalance-ui
|
|
|
120141 |
Banned CPU numbers: 73
|
|
|
120141 |
|
|
|
120141 |
Fixes: 76d1c9d73935 ("Add main user interface files")
|
|
|
120141 |
|
|
|
120141 |
Signed-off-by: Liu Chao <liuchao173@huawei.com>
|
|
|
120141 |
---
|
|
|
120141 |
ui/irqbalance-ui.c | 7 +++++--
|
|
|
120141 |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
120141 |
|
|
|
120141 |
diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c
|
|
|
120141 |
index 47b6c88..b7f9b62 100644
|
|
|
120141 |
--- a/ui/irqbalance-ui.c
|
|
|
120141 |
+++ b/ui/irqbalance-ui.c
|
|
|
120141 |
@@ -142,7 +142,7 @@ try_again:
|
|
|
120141 |
void parse_setup(char *setup_data)
|
|
|
120141 |
{
|
|
|
120141 |
char *token, *ptr;
|
|
|
120141 |
- int i,j;
|
|
|
120141 |
+ int i,j, cpu = 0;
|
|
|
120141 |
char *copy;
|
|
|
120141 |
irq_t *new_irq = NULL;
|
|
|
120141 |
if((setup_data == NULL) || (strlen(setup_data) == 0)) return;
|
|
|
120141 |
@@ -179,14 +179,17 @@ void parse_setup(char *setup_data)
|
|
|
120141 |
if(strncmp(token, "BANNED", strlen("BANNED"))) goto out;
|
|
|
120141 |
token = strtok_r(NULL, " ", &ptr);
|
|
|
120141 |
for(i = strlen(token) - 1; i >= 0; i--) {
|
|
|
120141 |
+ if (token[i] == ',')
|
|
|
120141 |
+ continue;
|
|
|
120141 |
char *map = hex_to_bitmap(token[i]);
|
|
|
120141 |
for(j = 3; j >= 0; j--) {
|
|
|
120141 |
if(map[j] == '1') {
|
|
|
120141 |
uint64_t *banned_cpu = malloc(sizeof(uint64_t));
|
|
|
120141 |
- *banned_cpu = (4 * (strlen(token) - (i + 1)) + (4 - (j + 1)));
|
|
|
120141 |
+ *banned_cpu = cpu;
|
|
|
120141 |
setup.banned_cpus = g_list_append(setup.banned_cpus,
|
|
|
120141 |
banned_cpu);
|
|
|
120141 |
}
|
|
|
120141 |
+ cpu++;
|
|
|
120141 |
}
|
|
|
120141 |
free(map);
|
|
|
120141 |
|
|
|
120141 |
--
|
|
|
120141 |
2.33.1
|
|
|
120141 |
|