Commit 8d4925e9 authored by Matt Redfearn's avatar Matt Redfearn Committed by Ralf Baechle

MIPS: dma-default: Defend against NULL dev in massage_gfp_flags

This patch ensures that the dev parameter is checked for NULL before it
is dereferenced in massage_gfp_flags. If dev is NULL, then fall back
setting the GFP flag requested and available.
Signed-off-by: default avatarMatt Redfearn <matt.redfearn@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11919/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent fa0c879f
...@@ -88,19 +88,20 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp) ...@@ -88,19 +88,20 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
else else
#endif #endif
#if defined(CONFIG_ZONE_DMA32) && defined(CONFIG_ZONE_DMA) #if defined(CONFIG_ZONE_DMA32) && defined(CONFIG_ZONE_DMA)
if (dev->coherent_dma_mask < DMA_BIT_MASK(32)) if (dev == NULL || dev->coherent_dma_mask < DMA_BIT_MASK(32))
dma_flag = __GFP_DMA; dma_flag = __GFP_DMA;
else if (dev->coherent_dma_mask < DMA_BIT_MASK(64)) else if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
dma_flag = __GFP_DMA32; dma_flag = __GFP_DMA32;
else else
#endif #endif
#if defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_ZONE_DMA) #if defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_ZONE_DMA)
if (dev->coherent_dma_mask < DMA_BIT_MASK(64)) if (dev == NULL || dev->coherent_dma_mask < DMA_BIT_MASK(64))
dma_flag = __GFP_DMA32; dma_flag = __GFP_DMA32;
else else
#endif #endif
#if defined(CONFIG_ZONE_DMA) && !defined(CONFIG_ZONE_DMA32) #if defined(CONFIG_ZONE_DMA) && !defined(CONFIG_ZONE_DMA32)
if (dev->coherent_dma_mask < DMA_BIT_MASK(sizeof(phys_addr_t) * 8)) if (dev == NULL ||
dev->coherent_dma_mask < DMA_BIT_MASK(sizeof(phys_addr_t) * 8))
dma_flag = __GFP_DMA; dma_flag = __GFP_DMA;
else else
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment