rapidio/tsi721_dma: fix failure to obtain transaction descriptor
This is a bug fix for the situation when function tsi721_desc_get() fails to obtain a free transaction descriptor. The bug usually results in a memory access crash dump when data transfer scatter-gather list has more entries than size of hardware buffer descriptors ring. This fix ensures that error is properly returned to a caller instead of an invalid entry. This patch is applicable to kernel versions starting from v3.5. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com> Cc: Stef van Os <stef.van.os@prodrive-technologies.com> Cc: Vinod Koul <vinod.koul@intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: <stable@vger.kernel.org> [3.5+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b104a35d32
commit
0193ed8225
1 changed files with 7 additions and 1 deletions
|
@ -287,6 +287,12 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan)
|
|||
"desc %p not ACKed\n", tx_desc);
|
||||
}
|
||||
|
||||
if (ret == NULL) {
|
||||
dev_dbg(bdma_chan->dchan.device->dev,
|
||||
"%s: unable to obtain tx descriptor\n", __func__);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
i = bdma_chan->wr_count_next % bdma_chan->bd_num;
|
||||
if (i == bdma_chan->bd_num - 1) {
|
||||
i = 0;
|
||||
|
@ -297,7 +303,7 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan)
|
|||
tx_desc->txd.phys = bdma_chan->bd_phys +
|
||||
i * sizeof(struct tsi721_dma_desc);
|
||||
tx_desc->hw_desc = &((struct tsi721_dma_desc *)bdma_chan->bd_base)[i];
|
||||
|
||||
err_out:
|
||||
spin_unlock_bh(&bdma_chan->lock);
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue