Fix crash in setup_files() if no files are defined
authorJens Axboe <axboe@fb.com>
Sun, 6 Apr 2014 15:56:10 +0000 (09:56 -0600)
committerJens Axboe <axboe@fb.com>
Sun, 6 Apr 2014 15:56:10 +0000 (09:56 -0600)
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 <axboe@fb.com>
filesetup.c

index fa09219f62a2e2b93f0e001b2e7254da72e04e99..bf05b6f000e4caf6158c4f0783ca9d5806fa6cc8 100644 (file)
@@ -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.
         */
         * 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;
                uint64_t all_fs;
 
                fs = o->size / o->nr_files;