irqbalance/Checking-return-value-of-strdup-in-collect_full_irq_.patch
2019-11-19 14:11:38 +08:00

30 lines
829 B
Diff

From 7dafc4d5c8d8229f107c90d97f33a4094eb89c6e Mon Sep 17 00:00:00 2001
From: liuchao173 <liuchao173@huawei.com>
Date: Thu, 7 Nov 2019 09:12:42 +0000
Subject: [PATCH 1/8] backport: 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 2c8118a..87fae2f 100644
--- a/procinterrupts.c
+++ b/procinterrupts.c
@@ -188,6 +188,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.19.1