[PATCH] blktrace: fix possible crash on exit without ever opening an ofile
authorJens Axboe <axboe@suse.de>
Thu, 23 Feb 2006 13:51:17 +0000 (14:51 +0100)
committerJens Axboe <axboe@suse.de>
Thu, 23 Feb 2006 13:51:17 +0000 (14:51 +0100)
blktrace.c

index 9aefac77c435c74a9b82533d13666ff983972eb6..cac2c38b0eece0eb559232f8f45239dd57c87d25 100644 (file)
@@ -643,7 +643,7 @@ static void tip_ftrunc_final(struct thread_information *tip)
        /*
         * truncate to right size and cleanup mmap
         */
-       if (tip->ofile_mmap) {
+       if (tip->ofile_mmap && tip->ofile) {
                int ofd = fileno(tip->ofile);
 
                if (tip->fs_buf)
@@ -1382,7 +1382,8 @@ static void net_client_done(struct net_connection *nc)
                for (j = 0; j < nc->ncpus; j++) {
                        tip = &dip->threads[j];
 
-                       fclose(tip->ofile);
+                       if (tip->ofile)
+                               fclose(tip->ofile);
                }
 
                free(dip->threads);