]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
ce24883f33908c1ceeb0ecd42cd32b4ab04e0206
[thirdparty/kernel/stable-queue.git] /
1 From foo@baz Fri Feb 23 11:48:40 CET 2018
2 From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
3 Date: Mon, 20 Nov 2017 08:28:14 -0600
4 Subject: dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved
5
6 From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
7
8
9 [ Upstream commit 62a277d43d47e74972de44d33bd3763e31992414 ]
10
11 _xt_ is being dereferenced before it is null checked, hence there is a
12 potential null pointer dereference.
13
14 Fix this by moving the pointer dereference after _xt_ has been null
15 checked.
16
17 This issue was detected with the help of Coccinelle.
18
19 Fixes: 4483320e241c ("dmaengine: Use Pointer xt after NULL check.")
20 Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
21 Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
22 Signed-off-by: Vinod Koul <vinod.koul@intel.com>
23 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 ---
26 drivers/dma/at_hdmac.c | 4 +++-
27 1 file changed, 3 insertions(+), 1 deletion(-)
28
29 --- a/drivers/dma/at_hdmac.c
30 +++ b/drivers/dma/at_hdmac.c
31 @@ -709,7 +709,7 @@ atc_prep_dma_interleaved(struct dma_chan
32 unsigned long flags)
33 {
34 struct at_dma_chan *atchan = to_at_dma_chan(chan);
35 - struct data_chunk *first = xt->sgl;
36 + struct data_chunk *first;
37 struct at_desc *desc = NULL;
38 size_t xfer_count;
39 unsigned int dwidth;
40 @@ -721,6 +721,8 @@ atc_prep_dma_interleaved(struct dma_chan
41 if (unlikely(!xt || xt->numf != 1 || !xt->frame_size))
42 return NULL;
43
44 + first = xt->sgl;
45 +
46 dev_info(chan2dev(chan),
47 "%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n",
48 __func__, &xt->src_start, &xt->dst_start, xt->numf,