public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix array overflow in CFQ
@ 2010-10-19  9:10 Andi Kleen
  2010-10-19 10:01 ` Jens Axboe
  0 siblings, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2010-10-19  9:10 UTC (permalink / raw)
  To: axboe; +Cc: torvalds, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

gcc 4.5 complains when compiling a recent rc with

linux/block/cfq-iosched.c: In function ‘cfq_dispatch_requests’:
linux/block/cfq-iosched.c:2156:3: warning: array subscript is above array bounds

and it is right:

 slice = group_slice * count /
                max_t(unsigned, cfqg->busy_queues_avg[cfqd->serving_prio],
                      cfq_group_busy_queues_wl(cfqd->serving_prio, cfqd, cfqg));

busy_queues_avg can be indexed by this enum

enum wl_prio_t {
        BE_WORKLOAD = 0,
        RT_WORKLOAD = 1,
        IDLE_WORKLOAD = 2,
};

in cfqd->serving_prio, but is only declared as

unsigned int busy_queues_avg[2];

which is clearly off by one. Fix this here.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 block/cfq-iosched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 9eba291..76741da 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -185,7 +185,7 @@ struct cfq_group {
 	int nr_cfqq;
 
 	/* Per group busy queus average. Useful for workload slice calc. */
-	unsigned int busy_queues_avg[2];
+	unsigned int busy_queues_avg[3];
 	/*
 	 * rr lists of queues with requests, onle rr for each priority class.
 	 * Counts are embedded in the cfq_rb_root
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-10-21 17:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-19  9:10 [PATCH] Fix array overflow in CFQ Andi Kleen
2010-10-19 10:01 ` Jens Axboe
2010-10-19 11:49   ` Vivek Goyal
2010-10-19 11:55     ` Jens Axboe
2010-10-19 12:33     ` Vivek Goyal
2010-10-19 13:23       ` Andi Kleen
2010-10-19 15:05         ` Vivek Goyal
2010-10-21 16:53           ` Jeff Moyer
2010-10-21 17:16             ` Andi Kleen
2010-10-21 17:15               ` Jeff Moyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox