From 3768776c7b4f7f79f52dc025d50a5e2d214f5b2c Mon Sep 17 00:00:00 2001 From: liuchao173 <55137861+liuchao173@users.noreply.github.com> Date: Mon, 2 Dec 2019 19:46:53 +0800 Subject: [PATCH 1/2] free polscript if irqbalance exit polscript is alloced in parse_command_line and isn't freed when irqbalance exit --- irqbalance.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/irqbalance.c b/irqbalance.c index 7630e38..5134f9d 100644 --- a/irqbalance.c +++ b/irqbalance.c @@ -702,6 +702,8 @@ int main(int argc, char** argv) out: free_object_tree(); free_cl_opts(); + if (polscript) + free(polscript); /* Remove pidfile */ if (!foreground_mode && pidfile) From 6e4ef7f8a13147c15ac542f829b5a7b6a93ce239 Mon Sep 17 00:00:00 2001 From: liuchao173 <55137861+liuchao173@users.noreply.github.com> Date: Tue, 3 Dec 2019 09:30:40 +0800 Subject: [PATCH 2/2] free polscript to avoid resource leak free polscript when irqbalance exit or the same option is passed twice on the comand line --- irqbalance.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/irqbalance.c b/irqbalance.c index 5134f9d..e76d27b 100644 --- a/irqbalance.c +++ b/irqbalance.c @@ -153,6 +153,7 @@ static void parse_command_line(int argc, char **argv) add_cl_banned_irq((int)val); break; case 'l': + free(polscript); polscript = strdup(optarg); break; case 'm': @@ -702,8 +703,7 @@ int main(int argc, char** argv) out: free_object_tree(); free_cl_opts(); - if (polscript) - free(polscript); + free(polscript); /* Remove pidfile */ if (!foreground_mode && pidfile)