Re: [PATCH 1/2] dma-mapping: Protect dma_addressing_limited against NULL dma_mask

From: Auger Eric
Date: Mon Jul 22 2019 - 11:46:08 EST


Hi Christoph,

On 7/22/19 5:26 PM, Christoph Hellwig wrote:
>> static inline bool dma_addressing_limited(struct device *dev)
>> {
>> - return min_not_zero(*dev->dma_mask, dev->bus_dma_mask) <
>> - dma_get_required_mask(dev);
>> + return WARN_ON_ONCE(!dev->dma_mask) ? false :
>> + min_not_zero(*dev->dma_mask, dev->bus_dma_mask) <
>> + dma_get_required_mask(dev);
>
> This should really use a separate if statement, but I can fix that
> up when applying it.
>
Just wondering why we don't use the dma_get_mask() accessor which
returns DMA_BIT_MASK(32) in case the dma_mask is not set.

Do you foresee any issue and would it still mandate to add dma_mask
checks on each call sites?

Thanks

Eric