[PATCH] acpi: fan: skip over fan info when the type field is NULL (LP: #1906540)

Colin King colin.king at canonical.com
Wed Dec 2 23:53:28 UTC 2020


From: Colin Ian King <colin.king at canonical.com>

It is possible for a read error on the thermal type field to end up
with a null type field. (This can occur when a snap is not installed
in --devmode and cannot access thermal control data).  This causes a
segmentation fault when dereferencing the pointer. Add null checks to
skip over such empty data fields.

Fixes: 10b9561f46f8 ("apci: fan: use newer thermal interface, test fans on loaded CPU (LP: #831905)")
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpi/fan/fan.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/acpi/fan/fan.c b/src/acpi/fan/fan.c
index a42ad673..d31f51de 100644
--- a/src/acpi/fan/fan.c
+++ b/src/acpi/fan/fan.c
@@ -215,9 +215,16 @@ static int fan_test2(fwts_framework *fw)
 
 	fwts_list_foreach(item1, fans1) {
 		fan_info *info1 = fwts_list_data(fan_info *, item1);
+
+		if (!info1->type)
+			continue;
+
 		fwts_list_foreach(item2, fans2) {
 			fan_info *info2 = fwts_list_data(fan_info *, item2);
 
+			if (!info2->type)
+				continue;
+
 			if (strcmp(info1->type, "Processor") == 0) {
 				if (strcmp(info1->name, info2->name) == 0) {
 					if (info2->cur_state < info1->cur_state) {
-- 
2.29.2




More information about the fwts-devel mailing list