Commit dbf4b7669c09f307124af3a479e0ca5b5361740c

Authored by Heinrich Schuchardt
Committed by Daniel Schwierzeck
1 parent d3611c991e

mips: micronas/vct: check array bounds before access

If we check an index against array bounds, we should do so before
accessing the array and not afterwards.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

board/micronas/vct/scc.c
... ... @@ -524,11 +524,13 @@
524 524 struct scc_dma_state *dma_state;
525 525 int return_value = 0;
526 526 union scc_dma_cfg dma_cfg;
527   - u32 *buffer_tag_list = scc_descriptor_table[id].buffer_tag_list;
  527 + u32 *buffer_tag_list;
528 528 u32 tag_count, t, t_valid;
529 529  
530 530 if ((id >= SCC_MAX) || (id < 0))
531 531 return -EINVAL;
  532 +
  533 + buffer_tag_list = scc_descriptor_table[id].buffer_tag_list;
532 534  
533 535 /* if the register is only configured by hw, cannot write! */
534 536 if (1 == scc_descriptor_table[id].hw_dma_cfg)