2019-03-23 22:40:45

by Kangjie Lu

[permalink] [raw]
Subject: [PATCH] dma: ti: fix a missing check in omap_dma_prep_dma_cyclic

It is invalid when "buf_len" is not aligned with "period_len".

The fix adds a check for the alignment.

Signed-off-by: Kangjie Lu <[email protected]>
---
drivers/dma/ti/omap-dma.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
index a4a931ddf6f6..5f0ce1975e52 100644
--- a/drivers/dma/ti/omap-dma.c
+++ b/drivers/dma/ti/omap-dma.c
@@ -1065,6 +1065,9 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
unsigned es;
u32 burst;

+ if (buf_len % period_len)
+ return NULL;
+
if (dir == DMA_DEV_TO_MEM) {
dev_addr = c->cfg.src_addr;
dev_width = c->cfg.src_addr_width;
--
2.17.1



2019-03-29 13:21:37

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH] dma: ti: fix a missing check in omap_dma_prep_dma_cyclic



On 24/03/2019 0.39, Kangjie Lu wrote:
> It is invalid when "buf_len" is not aligned with "period_len".
>
> The fix adds a check for the alignment.
>
> Signed-off-by: Kangjie Lu <[email protected]>
> ---
> drivers/dma/ti/omap-dma.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
> index a4a931ddf6f6..5f0ce1975e52 100644
> --- a/drivers/dma/ti/omap-dma.c
> +++ b/drivers/dma/ti/omap-dma.c
> @@ -1065,6 +1065,9 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
> unsigned es;
> u32 burst;
>
> + if (buf_len % period_len)
> + return NULL;
> +

if it really happens, then it might be better to do the check in
dmaengine_prep_dma_cyclic() rather than fixing _all_ drivers?

> if (dir == DMA_DEV_TO_MEM) {
> dev_addr = c->cfg.src_addr;
> dev_width = c->cfg.src_addr_width;
>

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki