summaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorDenis Orlov <denorl2009@gmail.com>2023-02-10 17:47:42 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2023-02-13 10:02:01 +0100
commit8e2327036285181c6168958d54ed1d135aeb9b7d (patch)
tree65a833e5508919d01498b041118a0847beb6b76d /arch/mips
parent6652ffcdab4716f2bf0b3bb75d79069ec1698ec6 (diff)
downloadbarebox-8e2327036285181c6168958d54ed1d135aeb9b7d.tar.gz
barebox-8e2327036285181c6168958d54ed1d135aeb9b7d.tar.xz
MIPS: dma: fix nullptr handling in dma_free_coherent
It is not an error to pass a null pointer to free() and as such it seems that dma_free_coherent() should be able to handle this situation too. Currently, if CONFIG_MMU option is enabled, we would convert this null pointer into a pointer to the beginning of CKSEG0 memory segment before passing it to free(), actually trying to deallocate stuff. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Link: https://lore.barebox.org/20230210144745.915720-2-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/include/asm/dma-mapping.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index 8e6ea08168..9f6ec03e3b 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -31,7 +31,7 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
size_t size)
{
- if (IS_ENABLED(CONFIG_MMU))
+ if (IS_ENABLED(CONFIG_MMU) && vaddr)
free((void *)CKSEG0ADDR(vaddr));
else
free(vaddr);