aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Fröhlich2009-11-03 10:41:26 -0600
committerAlex Deucher2009-11-03 10:41:26 -0600
commit6eafd1cf386d93bb9e34660227ca6f26aadfeb32 (patch)
tree2cbd0093758ec8fdbc43d88832aabfbd0345c083 /libdrm/radeon/radeon_cs_gem.c
parentb0b96636dbf93445dd532b09b21fa4fc5ce6bdc7 (diff)
downloadexternal-libgbm-6eafd1cf386d93bb9e34660227ca6f26aadfeb32.tar.gz
external-libgbm-6eafd1cf386d93bb9e34660227ca6f26aadfeb32.tar.xz
external-libgbm-6eafd1cf386d93bb9e34660227ca6f26aadfeb32.zip
radeon: fix allocation
The old code increments the command stream size by another kbyte, but does not make sure that the requested packet size fits into the stream. The patch ensures that the whole next packet fits there and rounds the allocated size to a power of two. Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Diffstat (limited to 'libdrm/radeon/radeon_cs_gem.c')
-rw-r--r--libdrm/radeon/radeon_cs_gem.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libdrm/radeon/radeon_cs_gem.c b/libdrm/radeon/radeon_cs_gem.c
index e42ec48f..232ea7f3 100644
--- a/libdrm/radeon/radeon_cs_gem.c
+++ b/libdrm/radeon/radeon_cs_gem.c
@@ -226,7 +226,8 @@ static int cs_gem_begin(struct radeon_cs *cs,
226 if (cs->cdw + ndw > cs->ndw) { 226 if (cs->cdw + ndw > cs->ndw) {
227 uint32_t tmp, *ptr; 227 uint32_t tmp, *ptr;
228 228
229 tmp = (cs->ndw + 1 + 0x3FF) & (~0x3FF); 229 /* round up the required size to a multiple of 1024 */
230 tmp = (cs->cdw + ndw + 0x3FF) & (~0x3FF);
230 ptr = (uint32_t*)realloc(cs->packets, 4 * tmp); 231 ptr = (uint32_t*)realloc(cs->packets, 4 * tmp);
231 if (ptr == NULL) { 232 if (ptr == NULL) {
232 return -ENOMEM; 233 return -ENOMEM;