Skip to content

Commit 5e5c793

Browse files
keesvinodkoul
authored andcommitted
dmaengine: ti: omap-dma: Initialize sglen after allocation
With the new __counted_by annocation, the "sglen" struct member must be set before accessing the "sg" array. This initialization was done in other places where a new struct omap_desc is allocated, but these cases were missed. Set "sglen" after allocation. Fixes: b851786 ("dmaengine: ti: omap-dma: Annotate struct omap_desc with __counted_by") Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 2ebc36b commit 5e5c793

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/dma/ti/omap-dma.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,10 +1186,10 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic(
11861186
d->dev_addr = dev_addr;
11871187
d->fi = burst;
11881188
d->es = es;
1189+
d->sglen = 1;
11891190
d->sg[0].addr = buf_addr;
11901191
d->sg[0].en = period_len / es_bytes[es];
11911192
d->sg[0].fn = buf_len / period_len;
1192-
d->sglen = 1;
11931193

11941194
d->ccr = c->ccr;
11951195
if (dir == DMA_DEV_TO_MEM)
@@ -1258,10 +1258,10 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_memcpy(
12581258
d->dev_addr = src;
12591259
d->fi = 0;
12601260
d->es = data_type;
1261+
d->sglen = 1;
12611262
d->sg[0].en = len / BIT(data_type);
12621263
d->sg[0].fn = 1;
12631264
d->sg[0].addr = dest;
1264-
d->sglen = 1;
12651265
d->ccr = c->ccr;
12661266
d->ccr |= CCR_DST_AMODE_POSTINC | CCR_SRC_AMODE_POSTINC;
12671267

@@ -1309,14 +1309,14 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_interleaved(
13091309
if (data_type > CSDP_DATA_TYPE_32)
13101310
data_type = CSDP_DATA_TYPE_32;
13111311

1312+
d->sglen = 1;
13121313
sg = &d->sg[0];
13131314
d->dir = DMA_MEM_TO_MEM;
13141315
d->dev_addr = xt->src_start;
13151316
d->es = data_type;
13161317
sg->en = xt->sgl[0].size / BIT(data_type);
13171318
sg->fn = xt->numf;
13181319
sg->addr = xt->dst_start;
1319-
d->sglen = 1;
13201320
d->ccr = c->ccr;
13211321

13221322
src_icg = dmaengine_get_src_icg(xt, &xt->sgl[0]);

0 commit comments

Comments
 (0)