From d1805c2f00a1099244b9e3fa06873d068c55607c Mon Sep 17 00:00:00 2001 From: fef Date: Tue, 10 Aug 2021 18:07:55 +0200 Subject: [PATCH] dma: make memory allocations atomic --- kernel/dma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/dma.c b/kernel/dma.c index dee0573..d3d2daf 100644 --- a/kernel/dma.c +++ b/kernel/dma.c @@ -18,7 +18,11 @@ static void dmabuf_destroy(struct kent *kent) struct dmabuf *dmabuf_create(struct device *dev, size_t len) { int err = 0; - struct dmabuf *buf = malloc(sizeof(*buf) + len); + /* + * allocation needs to be atomic because the buffer might be + * free()d from within an irq handler which cannot sleep + */ + struct dmabuf *buf = atomic_malloc(sizeof(*buf) + len); if (buf == NULL) return NULL;