Skip to content

Commit e51af02

Browse files
committed
sdma: fix off-by-one in the event bound check
The event-number range check used a strict greater-than against the event count, allowing the count value itself to index one past the array. Use greater-or-equal, in both the enable and disable paths. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 5a52ae2 commit e51af02

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/drivers/imx/sdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ static void sdma_enable_event(struct dma_chan_data *channel, int eventnum)
443443

444444
tr_dbg(&sdma_tr, "channel %d, event %d", channel->index, eventnum);
445445

446-
if (eventnum < 0 || eventnum > SDMA_HWEVENTS_COUNT)
446+
if (eventnum < 0 || eventnum >= SDMA_HWEVENTS_COUNT)
447447
return; /* No change if request is invalid */
448448

449449
dma_reg_update_bits(channel->dma, SDMA_CHNENBL(eventnum),
@@ -461,7 +461,7 @@ static void sdma_disable_event(struct dma_chan_data *channel, int eventnum)
461461
{
462462
tr_dbg(&sdma_tr, "channel %d, event %d", channel->index, eventnum);
463463

464-
if (eventnum < 0 || eventnum > SDMA_HWEVENTS_COUNT)
464+
if (eventnum < 0 || eventnum >= SDMA_HWEVENTS_COUNT)
465465
return; /* No change if request is invalid */
466466

467467
dma_reg_update_bits(channel->dma, SDMA_CHNENBL(eventnum),

0 commit comments

Comments
 (0)