[systemd-devel] [PATCH] bootchart: oom-check correct variable

Andreas Henriksson andreas at fatal.se
Tue Sep 16 10:40:25 PDT 2014


Coverity warned that we have already dereferenced ps->sample before
null-checking it. I suspect that's not really the issue and that
the check is checking the wrong variable.
Likely the oom-check should be on the just allocated ps->sample->next.

Found by coverity. Fixes: CID#1237765
---
 src/bootchart/store.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index 2d2ea42..e6aafd8 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -394,7 +394,7 @@ schedstat_next:
                         continue;
 
                 ps->sample->next = new0(struct ps_sched_struct, 1);
-                if (!ps->sample) {
+                if (!ps->sample->next) {
                         log_oom();
                         exit(EXIT_FAILURE);
                 }
-- 
2.1.0



More information about the systemd-devel mailing list