iowatcher: Fix crash due to missing queue action
authorJan Kara <jack@suse.cz>
Tue, 23 Oct 2012 09:05:31 +0000 (11:05 +0200)
committerChris Mason <clm@fb.com>
Wed, 24 Sep 2014 19:02:07 +0000 (12:02 -0700)
When queue action was missing from a trace, handling of dispatch didn't
quite get things right and crashed due to NULL pointer dereference.
Fix it.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
iowatcher/blkparse.c

index 84c26e1a56a2a7529b2c453c3507f0024d786a6b..f81b8315d106fb937b5f8baa4d751883cd81d3be 100644 (file)
@@ -246,7 +246,7 @@ static struct pending_io *io_hash_table_search(u64 sector)
        return NULL;
 }
 
-static int hash_queued_io(struct blk_io_trace *io)
+static struct pending_io *hash_queued_io(struct blk_io_trace *io)
 {
        struct pending_io *pio;
        int ret;
@@ -259,9 +259,9 @@ static int hash_queued_io(struct blk_io_trace *io)
        if (ret < 0) {
                /* crud, the IO is there already */
                free(pio);
-               return ret;
+               return NULL;
        }
-       return 0;
+       return pio;
 }
 
 static struct pending_io *hash_dispatched_io(struct blk_io_trace *io)
@@ -269,8 +269,11 @@ static struct pending_io *hash_dispatched_io(struct blk_io_trace *io)
        struct pending_io *pio;
 
        pio = io_hash_table_search(io->sector);
-       if (!pio)
-               hash_queued_io(io);
+       if (!pio) {
+               pio = hash_queued_io(io);
+               if (!pio)
+                       return NULL;
+       }
        pio->dispatch_time = io->time;
        return pio;
 }