summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-07-11 10:53:37 -0700
committerAlyssa Rosenzweig <[email protected]>2019-07-12 15:31:47 -0700
commit085004cc2caa4fd3db9fadf57f6004b11ef5866a (patch)
treec3a03574dda81bb7dc94b75123743b7159560ed1
parent8419621176502f906aac80601eecfcdce5324ff4 (diff)
panfrost/drm: Check allocation size is positive
Zero-sized allocations will fail with an unhelpful errno from the kernel; check size explicitly in userspace before it gets that far. Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r--src/gallium/drivers/panfrost/pan_drm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
index 882523d21de..6f29ef81437 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -84,6 +84,10 @@ panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
uint32_t flags)
{
struct panfrost_bo *bo = rzalloc(screen, struct panfrost_bo);
+
+ /* Kernel will fail (confusingly) with EPERM otherwise */
+ assert(size > 0);
+
struct drm_panfrost_create_bo create_bo = {
.size = size,
.flags = flags,