Skip to content

Commit 945b5af

Browse files
andy-shevVinod Koul
authored andcommitted
dmatest: allocate memory for pq_coefs from heap
This will help in future to hide a global variable usage. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent 77101ce commit 945b5af

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎drivers/dma/dmatest.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static int dmatest_func(void *data)
278278
dma_cookie_t cookie;
279279
enum dma_status status;
280280
enum dma_ctrl_flags flags;
281-
u8 pq_coefs[pq_sources + 1];
281+
u8 *pq_coefs = NULL;
282282
int ret;
283283
int src_cnt;
284284
int dst_cnt;
@@ -302,10 +302,15 @@ static int dmatest_func(void *data)
302302
/* force odd to ensure dst = src */
303303
src_cnt = min_odd(pq_sources | 1, dma_maxpq(dev, 0));
304304
dst_cnt = 2;
305+
306+
pq_coefs = kmalloc(pq_sources+1, GFP_KERNEL);
307+
if (!pq_coefs)
308+
goto err_thread_type;
309+
305310
for (i = 0; i < src_cnt; i++)
306311
pq_coefs[i] = 1;
307312
} else
308-
goto err_srcs;
313+
goto err_thread_type;
309314

310315
thread->srcs = kcalloc(src_cnt+1, sizeof(u8 *), GFP_KERNEL);
311316
if (!thread->srcs)
@@ -533,6 +538,8 @@ static int dmatest_func(void *data)
533538
err_srcbuf:
534539
kfree(thread->srcs);
535540
err_srcs:
541+
kfree(pq_coefs);
542+
err_thread_type:
536543
pr_notice("%s: terminating after %u tests, %u failures (status %d)\n",
537544
thread_name, total_tests, failed_tests, ret);
538545

0 commit comments

Comments
 (0)