Skip to contentSkip to conversation

Patch "dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Dec 6, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
dmaengine-stm32-dma-fix-null-pointer-dereference-in-stm32_dma_tx_status.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Wed Dec 6 17:39:55 CET 2017

From: M'boumba Cedric Madianga <[email protected]>
Date: Tue, 13 Dec 2016 14:40:46 +0100
Subject: dmaengine: stm32-dma: Fix null pointer dereference in stm32_dma_tx_status

From: M'boumba Cedric Madianga <[email protected]>

[ Upstream commit 57b5a32135c813f2ab669039fb4ec16b30cb3305 ]

chan->desc is always set to NULL when a DMA transfer is complete. As a DMA transfer could be complete during the call of stm32_dma_tx_status, we need to be sure that chan->desc is not NULL before using this variable to avoid a null pointer deference issue.

---
 drivers/dma/stm32-dma.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/dma/stm32-dma.c +3 -7
@@ -884,7 +884,7 @@ static enum dma_status stm32_dma_tx_stat
 	struct virt_dma_desc *vdesc;
 	enum dma_status status;
 	unsigned long flags;
-	u32 residue;
+	u32 residue = 0;
 
 	status = dma_cookie_status(c, cookie, state);
 	if ((status == DMA_COMPLETE) || (!state))
@@ -892,16 +892,12 @@ static enum dma_status stm32_dma_tx_stat
 
 	spin_lock_irqsave(&chan->vchan.lock, flags);
 	vdesc = vchan_find_desc(&chan->vchan, cookie);
-	if (cookie == chan->desc->vdesc.tx.cookie) {
+	if (chan->desc && cookie == chan->desc->vdesc.tx.cookie)
 		residue = stm32_dma_desc_residue(chan, chan->desc,
 						 chan->next_sg);
-	} else if (vdesc) {
+	else if (vdesc)
 		residue = stm32_dma_desc_residue(chan,
 						 to_stm32_dma_desc(vdesc), 0);
-	} else {
-		residue = 0;
-	}
-
 	dma_set_residue(state, residue);
 
 	spin_unlock_irqrestore(&chan->vchan.lock, flags);

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/dmaengine-stm32-dma-fix-null-pointer-dereference-in-stm32_dma_tx_status.patch queue-4.9/dmaengine-stm32-dma-set-correct-args-number-for-dma-request-from-dt.patch