This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Negative channel number crashes edma driver

A negative (or very large) channel number causes a segmentation fault in edma_free_channel.

void edma_free_channel(unsigned channel)
{
   unsigned ctlr;

   ctlr = EDMA_CTLR(channel);
   channel = EDMA_CHAN_SLOT(channel);

   if (channel >= edma_info[ctlr]->num_channels)
      return;


If channel is negative or large then ctlr is also large causing a segmentation fault in the channel validation conditional statement.

This can happen if allocating a channel returns a negative number that indicates allocation failure which is mistakenly passed to the free routine during cleanup.

Whilst this is an error condition it should be flagged as such.