Mesa (master): vc4: Avoid overflowing various static tables.
Eric Anholt
anholt at kemper.freedesktop.org
Thu Jul 30 22:52:08 UTC 2015
Module: Mesa
Branch: master
Commit: 86541cf8cea77f4b887dd061e7d6e3e4767f86fd
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=86541cf8cea77f4b887dd061e7d6e3e4767f86fd
Author: Eric Anholt <eric at anholt.net>
Date: Wed Jul 29 14:40:10 2015 -0700
vc4: Avoid overflowing various static tables.
---
src/gallium/drivers/vc4/kernel/vc4_validate.c | 2 +-
src/gallium/drivers/vc4/vc4_cl_dump.c | 2 +-
src/gallium/drivers/vc4/vc4_formats.c | 2 +-
src/gallium/drivers/vc4/vc4_qpu_disasm.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate.c b/src/gallium/drivers/vc4/kernel/vc4_validate.c
index cba948a..674ca63 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_validate.c
+++ b/src/gallium/drivers/vc4/kernel/vc4_validate.c
@@ -487,7 +487,7 @@ vc4_validate_bin_cl(struct drm_device *dev,
u8 cmd = *(uint8_t *)src_pkt;
const struct cmd_info *info;
- if (cmd > ARRAY_SIZE(cmd_info)) {
+ if (cmd >= ARRAY_SIZE(cmd_info)) {
DRM_ERROR("0x%08x: packet %d out of bounds\n",
src_offset, cmd);
return -EINVAL;
diff --git a/src/gallium/drivers/vc4/vc4_cl_dump.c b/src/gallium/drivers/vc4/vc4_cl_dump.c
index e153a24..6d74801 100644
--- a/src/gallium/drivers/vc4/vc4_cl_dump.c
+++ b/src/gallium/drivers/vc4/vc4_cl_dump.c
@@ -397,7 +397,7 @@ vc4_dump_cl(void *cl, uint32_t size, bool is_render)
while (offset < size) {
uint8_t header = cmds[offset];
- if (header > ARRAY_SIZE(packet_info) ||
+ if (header >= ARRAY_SIZE(packet_info) ||
!packet_info[header].name) {
fprintf(stderr, "0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n",
offset, hw_offset, header, header);
diff --git a/src/gallium/drivers/vc4/vc4_formats.c b/src/gallium/drivers/vc4/vc4_formats.c
index 004bac7..ffce612 100644
--- a/src/gallium/drivers/vc4/vc4_formats.c
+++ b/src/gallium/drivers/vc4/vc4_formats.c
@@ -108,7 +108,7 @@ static const struct vc4_format vc4_format_table[] = {
static const struct vc4_format *
get_format(enum pipe_format f)
{
- if (f > ARRAY_SIZE(vc4_format_table) ||
+ if (f >= ARRAY_SIZE(vc4_format_table) ||
!vc4_format_table[f].present)
return NULL;
else
diff --git a/src/gallium/drivers/vc4/vc4_qpu_disasm.c b/src/gallium/drivers/vc4/vc4_qpu_disasm.c
index 55e0e61..00aeb30 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_disasm.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_disasm.c
@@ -225,7 +225,7 @@ static const char *qpu_condflags[] = {
};
#define DESC(array, index) \
- ((index > ARRAY_SIZE(array) || !(array)[index]) ? \
+ ((index >= ARRAY_SIZE(array) || !(array)[index]) ? \
"???" : (array)[index])
static const char *
More information about the mesa-commit
mailing list