[PATCH] lib: fwts_klog: return list null when klog read returns zero length
Ivan Hu
ivan.hu at canonical.com
Tue Jul 22 08:32:00 UTC 2025
BugLink: https://bugs.launchpad.net/fwts/+bug/2117470
When `klogctl(3, buffer, len)` returns 0, it indicates that the kernel log is empty.
In this case, `fwts_klog_read()` should return NULL to reflect the absence of log data.
This situation can occur after executing `dmesg -C`, which clears the kernel log buffer.
Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
src/lib/src/fwts_klog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
index 3f9ffa7f..3bb57156 100644
--- a/src/lib/src/fwts_klog.c
+++ b/src/lib/src/fwts_klog.c
@@ -75,7 +75,7 @@ fwts_list *fwts_klog_read(void)
if ((buffer = calloc(1, len)) == NULL)
return NULL;
- if (klogctl(3, buffer, len) < 0) {
+ if (klogctl(3, buffer, len) <= 0) {
free(buffer);
return NULL;
}
--
2.34.1
More information about the fwts-devel
mailing list