From 79d615306f3a4146bb27d59c4b1707907099f669 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Tue, 23 Oct 2012 11:05:31 +0200 Subject: [PATCH] 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 Signed-off-by: Chris Mason --- iowatcher/blkparse.c | 13 ++++++++----- 1 file 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; } -- 2.25.1