From d1e78e6b0429bac92794fb6f1c24b5078c68da6d Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sun, 6 Apr 2014 09:56:10 -0600 Subject: [PATCH] Fix crash in setup_files() if no files are defined Commit 002fe73409d1e moved the division by o->nr_files outside of the file loop, so for error cases we could end up with doing the division without having files defined. Crash ensues. Signed-off-by: Jens Axboe --- filesetup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesetup.c b/filesetup.c index fa09219f..bf05b6f0 100644 --- a/filesetup.c +++ b/filesetup.c @@ -806,7 +806,7 @@ int setup_files(struct thread_data *td) * Calculate per-file size and potential extra size for the * first files, if needed. */ - if (!o->file_size_low) { + if (!o->file_size_low && o->nr_files) { uint64_t all_fs; fs = o->size / o->nr_files; -- 2.25.1