irqbalance/Checking-return-value-of-strdup-in-collect_full_irq_.patch
2020-07-03 17:09:39 +08:00

31 lines
822 B
Diff

From 7265665307ab991d0aa452e0b4590b3c1072d0a0 Mon Sep 17 00:00:00 2001
From: Yunfeng Ye <yeyunfeng@huawei.com>
Date: Sun, 22 Sep 2019 13:40:35 +0800
Subject: [PATCH 18/53] Checking return value of strdup() in
collect_full_irq_list()
strdup() may return NULL if memory allocation fail, checking the return
value before reference.
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
procinterrupts.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/procinterrupts.c b/procinterrupts.c
index 44c5c76..f3f57ad 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -189,6 +189,8 @@ GList* collect_full_irq_list()
continue;
savedline = strdup(line);
+ if (!savedline)
+ break;
irq_name = strtok_r(savedline, " ", &savedptr);
if (strstr(irq_name, "xen-dyn") != NULL)
is_xen_dyn = 1;
--
2.23.0