[igt-dev] [PATCH i-g-t 07/21] overlay: Write out the assumption for kernel-provided data

Petri Latvala
2019-01-16T11:21:03Z

The code assumes (correctly) that perf_event_header's size is
non-zero. Write that out so static analysis also knows it.

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
overlay/gpu-perf.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/overlay/gpu-perf.c b/overlay/gpu-perf.c
index 5629f826..7addd78d 100644
--- a/overlay/gpu-perf.c
+++ b/overlay/gpu-perf.c
@@ -494,6 +494,7 @@ int gpu_perf_update(struct gpu_perf *gp)
const struct perf_event_header *header;

header = (const struct perf_event_header *)(data + (tail & mask));
+ assert(header->size > 0);
if (header->size > head - tail)
break;

--
2.19.1