From: Jens Axboe Date: Fri, 20 May 2016 20:36:34 +0000 (-0600) Subject: iolog: fix potential oops in iolog disabling X-Git-Tag: fio-2.10~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=2ab71dc4d39e29764f0f80a3559a0119247e1eb1 iolog: fix potential oops in iolog disabling Do it in the function, not in the caller. The log may be NULL. Signed-off-by: Jens Axboe --- diff --git a/stat.c b/stat.c index 146090e7..fc1efd40 100644 --- 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; }