iolog: fix potential oops in iolog disabling
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index 146090e7f168d232fd055bb1a110229e35c0466a..fc1efd4057bd29ffa41e4e45c6061cd4e50624e2 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1898,7 +1898,7 @@ static struct io_logs *regrow_log(struct io_log *iolog)
        int i;
 
        if (!iolog || iolog->disabled)
-               return NULL;
+               goto disable;
 
        cur_log = iolog_cur_log(iolog);
        if (!cur_log) {
@@ -1946,21 +1946,19 @@ static struct io_logs *regrow_log(struct io_log *iolog)
 
        iolog->pending->nr_samples = 0;
        return cur_log;
+disable:
+       if (iolog)
+               iolog->disabled = true;
+       return NULL;
 }
 
 void regrow_logs(struct thread_data *td)
 {
-       if (!regrow_log(td->slat_log))
-               td->slat_log->disabled = true;
-       if (!regrow_log(td->clat_log))
-               td->clat_log->disabled = true;
-       if (!regrow_log(td->lat_log))
-               td->lat_log->disabled = true;
-       if (!regrow_log(td->bw_log))
-               td->bw_log->disabled = true;
-       if (!regrow_log(td->iops_log))
-               td->iops_log->disabled = true;
-
+       regrow_log(td->slat_log);
+       regrow_log(td->clat_log);
+       regrow_log(td->lat_log);
+       regrow_log(td->bw_log);
+       regrow_log(td->iops_log);
        td->flags &= ~TD_F_REGROW_LOGS;
 }