teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0266-bootchart-oom-check-correct-variable.patch

Zbigniew Jędrzejewski-Szmek 62fe94
From d498a616075ebfd8025d66c4c4f725d24eb3aca3 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 62fe94
From: Andreas Henriksson <andreas@fatal.se>
Zbigniew Jędrzejewski-Szmek 62fe94
Date: Tue, 16 Sep 2014 19:40:25 +0200
Zbigniew Jędrzejewski-Szmek 62fe94
Subject: [PATCH] bootchart: oom-check correct variable
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
Coverity warned that we have already dereferenced ps->sample before
Zbigniew Jędrzejewski-Szmek 62fe94
null-checking it. I suspect that's not really the issue and that
Zbigniew Jędrzejewski-Szmek 62fe94
the check is checking the wrong variable.
Zbigniew Jędrzejewski-Szmek 62fe94
Likely the oom-check should be on the just allocated ps->sample->next.
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
Found by coverity. Fixes: CID#1237765
Zbigniew Jędrzejewski-Szmek 62fe94
---
Zbigniew Jędrzejewski-Szmek 62fe94
 src/bootchart/store.c | 2 +-
Zbigniew Jędrzejewski-Szmek 62fe94
 1 file changed, 1 insertion(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
Zbigniew Jędrzejewski-Szmek 62fe94
index ed46a503c6..ed683e88d9 100644
Zbigniew Jędrzejewski-Szmek 62fe94
--- a/src/bootchart/store.c
Zbigniew Jędrzejewski-Szmek 62fe94
+++ b/src/bootchart/store.c
Zbigniew Jędrzejewski-Szmek 62fe94
@@ -399,7 +399,7 @@ schedstat_next:
Zbigniew Jędrzejewski-Szmek 62fe94
                         continue;
Zbigniew Jędrzejewski-Szmek 62fe94
 
Zbigniew Jędrzejewski-Szmek 62fe94
                 ps->sample->next = new0(struct ps_sched_struct, 1);
Zbigniew Jędrzejewski-Szmek 62fe94
-                if (!ps->sample) {
Zbigniew Jędrzejewski-Szmek 62fe94
+                if (!ps->sample->next) {
Zbigniew Jędrzejewski-Szmek 62fe94
                         log_oom();
Zbigniew Jędrzejewski-Szmek 62fe94
                         exit(EXIT_FAILURE);
Zbigniew Jędrzejewski-Szmek 62fe94
                 }