[PATCH] blkparse: make sure new pci infos have ->fd initialized to -1
authorJens Axboe <axboe@suse.de>
Wed, 25 Jan 2006 23:27:28 +0000 (15:27 -0800)
committerJens Axboe <axboe@suse.de>
Wed, 25 Jan 2006 23:27:28 +0000 (15:27 -0800)
This avoids hangs in blktrace when seeing potentially invalid samples, since
it will attempt to read from fd == 0 (stdin) in that case.

blkparse.c

index e4804bc7b863615e324228039979fda82c093279..cf43370b04811adcef04067a728cf7569b396cbe 100644 (file)
@@ -810,6 +810,7 @@ static void resize_cpu_info(struct per_dev_info *pdi, int cpu)
        int ncpus = pdi->ncpus;
        int new_count = cpu + 1;
        int new_space, size;
+       int i;
        char *new_start;
 
        size = new_count * sizeof(struct per_cpu_info);
@@ -827,6 +828,9 @@ static void resize_cpu_info(struct per_dev_info *pdi, int cpu)
 
        pdi->ncpus = new_count;
        pdi->cpus = cpus;
+
+       for (i = cpu; i < new_count; i++)
+               pdi->cpus[i].fd = -1;
 }
 
 static struct per_cpu_info *get_cpu_info(struct per_dev_info *pdi, int cpu)