DMA Engine development
 help / color / mirror / Atom feed
* [PATCH v2] ioat: ioat_alloc_ring() failure handling.
@ 2019-12-25 17:55 Alexander.Barabash
  2019-12-26 15:48 ` Jiang, Dave
  2019-12-27  6:36 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander.Barabash @ 2019-12-25 17:55 UTC (permalink / raw)
  To: dmaengine; +Cc: alexander.barabash

If dma_alloc_coherent() returns NULL in ioat_alloc_ring(), ring
allocation must not proceed.

Until now, if the first call to dma_alloc_coherent() in
ioat_alloc_ring() returned NULL, the processing could proceed, failing
with NULL-pointer dereferencing further down the line.

Signed-off-by: Alexander Barabash <alexander.barabash@dell.com>
---
 drivers/dma/ioat/dma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 1a422a8..18c011e 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -377,10 +377,11 @@ struct ioat_ring_ent **
 
 		descs->virt = dma_alloc_coherent(to_dev(ioat_chan),
 						 SZ_2M, &descs->hw, flags);
-		if (!descs->virt && (i > 0)) {
+		if (!descs->virt) {
 			int idx;
 
 			for (idx = 0; idx < i; idx++) {
+				descs = &ioat_chan->descs[idx];
 				dma_free_coherent(to_dev(ioat_chan), SZ_2M,
 						  descs->virt, descs->hw);
 				descs->virt = NULL;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-27  6:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-25 17:55 [PATCH v2] ioat: ioat_alloc_ring() failure handling Alexander.Barabash
2019-12-26 15:48 ` Jiang, Dave
2019-12-27  6:36 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox