panfrost/drm: Check allocation size is positive
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 11 Jul 2019 17:53:37 +0000 (10:53 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 12 Jul 2019 22:31:47 +0000 (15:31 -0700)
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 <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_drm.c

index 882523d21de30075d70c239b91ffdca9939f9062..6f29ef814377532f46a89f3134a7142581a780e1 100644 (file)
@@ -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,