From a9f0290a6754a475eb95818dd38dc401370da071 Mon Sep 17 00:00:00 2001 From: liuchao173 <55137861+liuchao173@users.noreply.github.com> Date: Mon, 23 Aug 2021 19:40:41 +0800 Subject: [PATCH] fix opendir fails in check_platform_device When irq name does not contain spaces, savedptr is an empty string and irq_fullname will have a extra space at the end like " LNRO0005:00 ". So opendir in check_platform_device will fail, and irqbalance prints log: "No directory /sys/devices/platform/LNRO0005:00 /: No such file or directory" --- procinterrupts.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/procinterrupts.c b/procinterrupts.c index 32c5e53..2bd201b 100644 --- a/procinterrupts.c +++ b/procinterrupts.c @@ -183,20 +183,17 @@ void init_irq_class_and_type(char *savedline, struct irq_info *info, int irq) } #ifdef AARCH64 - irq_name = last_token; - tmp = strchr(irq_name, '\n'); - if (tmp) - *tmp = 0; - - if (strlen(irq_name) + strlen(savedptr) + 1 < PATH_MAX) { - strcat(irq_fullname, irq_name); - strcat(irq_fullname, " "); - strcat(irq_fullname, savedptr); - tmp = strchr(irq_fullname, '\n'); - if (tmp) - *tmp = 0; - } else { - irq_fullname_valid = 0; + if (strlen(savedptr) > 0) { + if (strlen(irq_name) + strlen(savedptr) + 1 < PATH_MAX) { + strcat(irq_fullname, irq_name); + strcat(irq_fullname, " "); + strcat(irq_fullname, savedptr); + tmp = strchr(irq_fullname, '\n'); + if (tmp) + *tmp = 0; + } else { + irq_fullname_valid = 0; + } } #endif irq_mod = last_token; -- 1.8.3.1