From f4f6053a06e8b084d66894f63f4de9697d921c27 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Wed, 20 Dec 2023 13:54:31 +0100 Subject: [PATCH] local: Fix segfault when destroying block If both the DMABUF and the MMAP APIs are enabled, and the kernel supports the DMABUF API, local_free_dmabuf() will be called. Therefore, the "pdata" pointer should never be deferenced after that point. Signed-off-by: Paul Cercueil --- local.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/local.c b/local.c index 37bf3ac91..47ea923f2 100644 --- a/local.c +++ b/local.c @@ -1546,8 +1546,7 @@ static void local_free_block(struct iio_block_pdata *pdata) { if (WITH_LOCAL_DMABUF_API && pdata->buf->dmabuf_supported) local_free_dmabuf(pdata); - - if (WITH_LOCAL_MMAP_API && pdata->buf->mmap_supported) + else if (WITH_LOCAL_MMAP_API && pdata->buf->mmap_supported) local_free_mmap_block(pdata); }