Skip to content

Commit

Permalink
dmaengine: dmatest: Add check for supported buffer count (sg_buffers)
Browse files Browse the repository at this point in the history
When using dmatest with sg_buffers=128 I stumbled upon the problem, that
the "map_cnt" variable of "struct dmaengine_unmap_data" was set to 0.
"map_cnt" is an "u8" variable, resulting in an overrun when its
value is set to src_cnt + dst_cnt, to twice the sg_buffer value.

This patch adds a small check to dmatest, so that this confusing error
is detected and the test is aborted.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Kedareswara rao Appana <appanad@xilinx.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
  • Loading branch information
Stefan Roese authored and Vinod Koul committed May 1, 2017
1 parent 58532e6 commit fbfb8e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/dma/dmatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,13 @@ static int dmatest_func(void *data)

total_tests++;

/* Check if buffer count fits into map count variable (u8) */
if ((src_cnt + dst_cnt) >= 255) {
pr_err("too many buffers (%d of 255 supported)\n",
src_cnt + dst_cnt);
break;
}

if (1 << align > params->buf_size) {
pr_err("%u-byte buffer too small for %d-byte alignment\n",
params->buf_size, 1 << align);
Expand Down

0 comments on commit fbfb8e1

Please sign in to comment.