summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-11-28 14:32:53 +0100
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-11-28 14:32:53 +0100
commit0aa2c59efc31896e94dc478741f540605b670c2d (patch)
treef2d039c1492b87f0ab1bf03e202d95679a40a9d2
parentcd35dd6d3f1343b8ec2590cf9bfc9a1bc41c4960 (diff)
downloadpcitool-0aa2c59efc31896e94dc478741f540605b670c2d.tar.gz
pcitool-0aa2c59efc31896e94dc478741f540605b670c2d.tar.bz2
pcitool-0aa2c59efc31896e94dc478741f540605b670c2d.tar.xz
pcitool-0aa2c59efc31896e94dc478741f540605b670c2d.zip
Fix allocation of big memory buffers for DMA readout in pcitool
-rw-r--r--cli.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cli.c b/cli.c
index e07a470..04a31e1 100644
--- a/cli.c
+++ b/cli.c
@@ -618,7 +618,7 @@ int ReadData(pcilib_t *handle, ACCESS_MODE mode, FLAGS flags, pcilib_dma_engine_
void *buf;
int i, err;
size_t ret, bytes;
- int size = n * abs(access);
+ size_t size = n * abs(access);
int block_width, blocks_per_line;
int numbers_per_block, numbers_per_line;
pcilib_dma_engine_t dmaid;
@@ -633,7 +633,7 @@ int ReadData(pcilib_t *handle, ACCESS_MODE mode, FLAGS flags, pcilib_dma_engine_
if (size) {
buf = malloc(size);
- if (!buf) Error("Allocation of %i bytes of memory have failed", size);
+ if (!buf) Error("Allocation of %zu bytes of memory has failed", size);
} else {
buf = NULL;
}
@@ -658,6 +658,7 @@ int ReadData(pcilib_t *handle, ACCESS_MODE mode, FLAGS flags, pcilib_dma_engine_
do {
size *= 2;
buf = realloc(buf, size);
+ if (!buf) Error("Allocation of %zu bytes of memory has failed", size);
err = pcilib_read_dma_custom(handle, dmaid, addr, size - bytes, dma_flags, timeout, buf + bytes, &ret);
bytes += ret;