diff options
author | Jan Kara <jack@suse.cz> | 2012-10-23 11:05:31 +0200 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-09-24 12:02:07 -0700 |
commit | 79d615306f3a4146bb27d59c4b1707907099f669 (patch) | |
tree | 97dafed12b478c760e5bc482fd35e6b19a249223 | |
parent | 776c17af8515db948e0c8cfcb06291d40f8d7779 (diff) | |
download | blktrace-79d615306f3a4146bb27d59c4b1707907099f669.tar.gz |
iowatcher: Fix crash due to missing queue action
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>
-rw-r--r-- | iowatcher/blkparse.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c index 84c26e1..f81b831 100644 --- a/iowatcher/blkparse.c +++ b/iowatcher/blkparse.c @@ -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; } |