Skip to content

Commit

Permalink
local: Fix segfault when destroying block
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pcercuei committed Dec 20, 2023
1 parent 7407bdf commit f4f6053
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit f4f6053

Please sign in to comment.