aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-05-05 05:57:44 -0400
committerVinod Koul <vinod.koul@intel.com>2017-05-14 08:52:08 -0400
commiteb8df543e444492328f506adffc7dfe94111f1bd (patch)
treecea4e75fd4682017869076d94ec57b4832be91da
parent2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff)
dmaengine: mv_xor_v2: handle mv_xor_v2_prep_sw_desc() error properly
The mv_xor_v2_prep_sw_desc() is called from a few different places in the driver, but we never take into account the fact that it might return NULL. This commit fixes that, ensuring that we don't panic if there are no more descriptors available. Fixes: 19a340b1a820 ("dmaengine: mv_xor_v2: new driver") Cc: <stable@vger.kernel.org> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/mv_xor_v2.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c
index a28a01fcba67..e9280207ac19 100644
--- a/drivers/dma/mv_xor_v2.c
+++ b/drivers/dma/mv_xor_v2.c
@@ -389,6 +389,8 @@ mv_xor_v2_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest,
389 __func__, len, &src, &dest, flags); 389 __func__, len, &src, &dest, flags);
390 390
391 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); 391 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev);
392 if (!sw_desc)
393 return NULL;
392 394
393 sw_desc->async_tx.flags = flags; 395 sw_desc->async_tx.flags = flags;
394 396
@@ -443,6 +445,8 @@ mv_xor_v2_prep_dma_xor(struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
443 __func__, src_cnt, len, &dest, flags); 445 __func__, src_cnt, len, &dest, flags);
444 446
445 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); 447 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev);
448 if (!sw_desc)
449 return NULL;
446 450
447 sw_desc->async_tx.flags = flags; 451 sw_desc->async_tx.flags = flags;
448 452
@@ -491,6 +495,8 @@ mv_xor_v2_prep_dma_interrupt(struct dma_chan *chan, unsigned long flags)
491 container_of(chan, struct mv_xor_v2_device, dmachan); 495 container_of(chan, struct mv_xor_v2_device, dmachan);
492 496
493 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev); 497 sw_desc = mv_xor_v2_prep_sw_desc(xor_dev);
498 if (!sw_desc)
499 return NULL;
494 500
495 /* set the HW descriptor */ 501 /* set the HW descriptor */
496 hw_descriptor = &sw_desc->hw_desc; 502 hw_descriptor = &sw_desc->hw_desc;