Check size of buffer before allocating
Avoid undefined behaviour from calling dma_alloc_coherent with
requested size=0 as reported by UBSAN.
Change-Id: I1732759464f1d88259edeea099b1729f4ae6b86f
diff --git a/kernel/ethosu_buffer.c b/kernel/ethosu_buffer.c
index cad73b2..4f70f1d 100644
--- a/kernel/ethosu_buffer.c
+++ b/kernel/ethosu_buffer.c
@@ -222,6 +222,9 @@
struct ethosu_buffer *buf;
int ret = -ENOMEM;
+ if (!capacity)
+ return -EINVAL;
+
buf = devm_kzalloc(edev->dev, sizeof(*buf), GFP_KERNEL);
if (!buf)
return -ENOMEM;