Re: [PATCH] dma-direct: Fix potential NULL pointer dereference
From: Christoph Hellwig
Date: Wed Sep 16 2020 - 02:20:09 EST
On Tue, Sep 15, 2020 at 04:46:17PM -0400, Thomas Tai wrote:
> I tried out the suggested changes, and it successfully warned the null
> pointer without panic. I notice that there are some places outside the
> dma-direct, which calls dma_capable().
>
> https://elixir.bootlin.com/linux/v5.9-rc5/source/arch/x86/kernel/amd_gart_64.c#L187
>
> https://elixir.bootlin.com/linux/v5.9-rc5/source/drivers/xen/swiotlb-xen.c#L387
All of these still come in throught the wrappers in kernel/dma/mapping.c.
> Given that the WARN_ON_ONCE already did the intended warning, would you be
> ok that I keep the null checking in dma_capable()?
No, the generic dma mapping layer is the right place.