chiark / gitweb /
bootchart: oom-check correct variable
authorAndreas Henriksson <andreas@fatal.se>
Tue, 16 Sep 2014 17:40:25 +0000 (19:40 +0200)
committerTom Gundersen <teg@jklm.no>
Tue, 16 Sep 2014 18:25:30 +0000 (20:25 +0200)
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

index ed46a50..ed683e8 100644 (file)
@@ -399,7 +399,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);
                 }