summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSergio Paracuellos <sergio.paracuellos@gmail.com>2018-10-20 13:31:06 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-07 13:08:28 +0100
commit354e379684fcc70ab8d5450b4d57bd92b5294dfd (patch)
tree290f57de41dbf34bdb711b5b80c62c38edc8ce7f /drivers
parent4dc2a3cd27856531cf92762fea2eb9468efe552f (diff)
downloadlinux-stable-354e379684fcc70ab8d5450b4d57bd92b5294dfd.tar.gz
linux-stable-354e379684fcc70ab8d5450b4d57bd92b5294dfd.tar.bz2
linux-stable-354e379684fcc70ab8d5450b4d57bd92b5294dfd.zip
staging: mt7621-dma: fix potentially dereferencing uninitialized 'tx_desc'
Function 'mtk_hsdma_start_transfer' uses 'tx_desc' pointer which can be dereferenced before it is initializated. Initializate pointer before avoiding the problem. Fixes: 0853c7a53eb3 ("staging: mt7621-dma: ralink: add rt2880 dma engine") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/mt7621-dma/mtk-hsdma.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c
index df6ebf41bdea..5831f816c17b 100644
--- a/drivers/staging/mt7621-dma/mtk-hsdma.c
+++ b/drivers/staging/mt7621-dma/mtk-hsdma.c
@@ -335,6 +335,8 @@ static int mtk_hsdma_start_transfer(struct mtk_hsdam_engine *hsdma,
/* tx desc */
src = sg->src_addr;
for (i = 0; i < chan->desc->num_sgs; i++) {
+ tx_desc = &chan->tx_ring[chan->tx_idx];
+
if (len > HSDMA_MAX_PLEN)
tlen = HSDMA_MAX_PLEN;
else
@@ -344,7 +346,6 @@ static int mtk_hsdma_start_transfer(struct mtk_hsdam_engine *hsdma,
tx_desc->addr1 = src;
tx_desc->flags |= HSDMA_DESC_PLEN1(tlen);
} else {
- tx_desc = &chan->tx_ring[chan->tx_idx];
tx_desc->addr0 = src;
tx_desc->flags = HSDMA_DESC_PLEN0(tlen);