5 Dec
2013
5 Dec
'13
10:07 p.m.
On Thu, Dec 05, 2013 at 09:11:50PM +0100, Takashi Iwai wrote:
Does the check of dma_to_pfn(dev, ~0) is really necessary?
Of course.
In get_coherent_dma_mask(), it checks further
if (dma_to_pfn(dev, mask) < max_dma_pfn) {
and since mask > ~0, this check should suffice, I think.
dma_to_pfn() takes a dma_addr_t as the second argument. At this point, we've ascertained that 'mask' is larger than dma_addr_t, so the above will truncate the mask.
The whole point of this is to protect the following code which does exactly that from this truncation.