Skip to content

Commit

Permalink
blktrace: fix off-by-one bug
Browse files Browse the repository at this point in the history
'what' is used as the index of array what2act, so it can't >= the array size.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Mar 31, 2009
1 parent 5554720 commit eb08f8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/trace/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ static enum print_line_t blk_trace_event_print(struct trace_iterator *iter,
if (!trace_print_context(iter))
return TRACE_TYPE_PARTIAL_LINE;

if (unlikely(what == 0 || what > ARRAY_SIZE(what2act)))
if (unlikely(what == 0 || what >= ARRAY_SIZE(what2act)))
ret = trace_seq_printf(s, "Bad pc action %x\n", what);
else {
const bool long_act = !!(trace_flags & TRACE_ITER_VERBOSE);
Expand Down Expand Up @@ -1199,7 +1199,7 @@ static enum print_line_t blk_tracer_print_line(struct trace_iterator *iter)
t = (const struct blk_io_trace *)iter->ent;
what = t->action & ((1 << BLK_TC_SHIFT) - 1);

if (unlikely(what == 0 || what > ARRAY_SIZE(what2act)))
if (unlikely(what == 0 || what >= ARRAY_SIZE(what2act)))
ret = trace_seq_printf(&iter->seq, "Bad pc action %x\n", what);
else {
const bool long_act = !!(trace_flags & TRACE_ITER_VERBOSE);
Expand Down

0 comments on commit eb08f8e

Please sign in to comment.