From 2ab71dc4d39e29764f0f80a3559a0119247e1eb1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 20 May 2016 14:36:34 -0600 Subject: [PATCH] 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 --- stat.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) 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; } -- 2.25.1