]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.133/dmaengine-ensure-dmaengine-helpers-check-valid-callback.patch
fix up queue-5.15/mm-fix-race-between-__split_huge_pmd_locked-and-gup-.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.4.133 / dmaengine-ensure-dmaengine-helpers-check-valid-callback.patch
1 From 757d12e5849be549076901b0d33c60d5f360269c Mon Sep 17 00:00:00 2001
2 From: Vinod Koul <vinod.koul@intel.com>
3 Date: Tue, 12 Apr 2016 21:07:06 +0530
4 Subject: dmaengine: ensure dmaengine helpers check valid callback
5
6 From: Vinod Koul <vinod.koul@intel.com>
7
8 commit 757d12e5849be549076901b0d33c60d5f360269c upstream.
9
10 dmaengine has various device callbacks and exposes helper
11 functions to invoke these. These helpers should check if channel,
12 device and callback is valid or not before invoking them.
13
14 Reported-by: Jon Hunter <jonathanh@nvidia.com>
15 Signed-off-by: Vinod Koul <vinod.koul@intel.com>
16 Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
17 Signed-off-by: Jianming Qiao <jianming.qiao@bp.renesas.com>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20 ---
21 include/linux/dmaengine.h | 20 +++++++++++++++++++-
22 1 file changed, 19 insertions(+), 1 deletion(-)
23
24 --- a/include/linux/dmaengine.h
25 +++ b/include/linux/dmaengine.h
26 @@ -767,6 +767,9 @@ static inline struct dma_async_tx_descri
27 sg_dma_address(&sg) = buf;
28 sg_dma_len(&sg) = len;
29
30 + if (!chan || !chan->device || !chan->device->device_prep_slave_sg)
31 + return NULL;
32 +
33 return chan->device->device_prep_slave_sg(chan, &sg, 1,
34 dir, flags, NULL);
35 }
36 @@ -775,6 +778,9 @@ static inline struct dma_async_tx_descri
37 struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len,
38 enum dma_transfer_direction dir, unsigned long flags)
39 {
40 + if (!chan || !chan->device || !chan->device->device_prep_slave_sg)
41 + return NULL;
42 +
43 return chan->device->device_prep_slave_sg(chan, sgl, sg_len,
44 dir, flags, NULL);
45 }
46 @@ -786,6 +792,9 @@ static inline struct dma_async_tx_descri
47 enum dma_transfer_direction dir, unsigned long flags,
48 struct rio_dma_ext *rio_ext)
49 {
50 + if (!chan || !chan->device || !chan->device->device_prep_slave_sg)
51 + return NULL;
52 +
53 return chan->device->device_prep_slave_sg(chan, sgl, sg_len,
54 dir, flags, rio_ext);
55 }
56 @@ -796,6 +805,9 @@ static inline struct dma_async_tx_descri
57 size_t period_len, enum dma_transfer_direction dir,
58 unsigned long flags)
59 {
60 + if (!chan || !chan->device || !chan->device->device_prep_dma_cyclic)
61 + return NULL;
62 +
63 return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len,
64 period_len, dir, flags);
65 }
66 @@ -804,6 +816,9 @@ static inline struct dma_async_tx_descri
67 struct dma_chan *chan, struct dma_interleaved_template *xt,
68 unsigned long flags)
69 {
70 + if (!chan || !chan->device || !chan->device->device_prep_interleaved_dma)
71 + return NULL;
72 +
73 return chan->device->device_prep_interleaved_dma(chan, xt, flags);
74 }
75
76 @@ -811,7 +826,7 @@ static inline struct dma_async_tx_descri
77 struct dma_chan *chan, dma_addr_t dest, int value, size_t len,
78 unsigned long flags)
79 {
80 - if (!chan || !chan->device)
81 + if (!chan || !chan->device || !chan->device->device_prep_dma_memset)
82 return NULL;
83
84 return chan->device->device_prep_dma_memset(chan, dest, value,
85 @@ -824,6 +839,9 @@ static inline struct dma_async_tx_descri
86 struct scatterlist *src_sg, unsigned int src_nents,
87 unsigned long flags)
88 {
89 + if (!chan || !chan->device || !chan->device->device_prep_dma_sg)
90 + return NULL;
91 +
92 return chan->device->device_prep_dma_sg(chan, dst_sg, dst_nents,
93 src_sg, src_nents, flags);
94 }