stat: fix --bandwidth-log segfault
authorIgor Konopko <igor.j.konopko@intel.com>
Fri, 8 Jun 2018 08:26:25 +0000 (10:26 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 8 Jun 2018 14:31:20 +0000 (08:31 -0600)
Since bandwidth log has no corresponding thread data
and pending struct, we cannot access any fields inside it.

Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
stat.c

diff --git a/stat.c b/stat.c
index 58edf047b34f51106889cb1f315baa00c3bcf783..d5240d96a25b7f2f8f8ffc69abefe2f47b12d322 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -2207,12 +2207,14 @@ static struct io_logs *get_cur_log(struct io_log *iolog)
         * submissions, flag 'td' as needing a log regrow and we'll take
         * care of it on the submission side.
         */
-       if (iolog->td->o.io_submit_mode == IO_MODE_OFFLOAD ||
+       if ((iolog->td && iolog->td->o.io_submit_mode == IO_MODE_OFFLOAD) ||
            !per_unit_log(iolog))
                return regrow_log(iolog);
 
-       iolog->td->flags |= TD_F_REGROW_LOGS;
-       assert(iolog->pending->nr_samples < iolog->pending->max_samples);
+       if (iolog->td)
+               iolog->td->flags |= TD_F_REGROW_LOGS;
+       if (iolog->pending)
+               assert(iolog->pending->nr_samples < iolog->pending->max_samples);
        return iolog->pending;
 }