Skip to content

Commit b0b5ce1

Browse files
Alexander.Barabash@dell.comvinodkoul
authored andcommitted
ioat: ioat_alloc_ring() failure handling.
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 <[email protected]> Acked-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 24461d9 commit b0b5ce1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/dma/ioat/dma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,11 @@ ioat_alloc_ring(struct dma_chan *c, int order, gfp_t flags)
377377

378378
descs->virt = dma_alloc_coherent(to_dev(ioat_chan),
379379
SZ_2M, &descs->hw, flags);
380-
if (!descs->virt && (i > 0)) {
380+
if (!descs->virt) {
381381
int idx;
382382

383383
for (idx = 0; idx < i; idx++) {
384+
descs = &ioat_chan->descs[idx];
384385
dma_free_coherent(to_dev(ioat_chan), SZ_2M,
385386
descs->virt, descs->hw);
386387
descs->virt = NULL;

0 commit comments

Comments
 (0)