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 <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig
2019-07-11 10:53:37 -07:00
parent 8419621176
commit 085004cc2c
+4
View 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,