x86/dma-mapping: Fix arch_dma_alloc_attrs() oops with NULL dev
x86/dma-mapping: Fix arch_dma_alloc_attrs() oops with NULL dev

Commit 6894258eda2f broke drivers that pass NULL as the device pointer
to dma_alloc. The reason is that arch_dma_alloc_attrs() now calls
dma_alloc_coherent_gfp_flags() which in turn calls
dma_alloc_coherent_mask(), where the device pointer is dereferenced
unconditionally.

Fix things by moving the ISA DMA fallback device assignment before the
call to dma_alloc_coherent_gfp_flags().

Fixes: 6894258eda2f ("dma-mapping: consolidate dma_{alloc,free}_{attrs,coherent}")
Reported-and-tested-by: Meelis Roos <c1c0388d3cdd4295e8ad201acc4082e735b9ca96@linux.ee>
Signed-off-by: Ville Syrjälä <cd6e8d405ca90be3a03d5427c5b24fbd2d68dcc4@linux.intel.com>
Cc: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@lst.de>
Link: http://lkml.kernel.org/r/1445807503-8920-1-git-send-email-cd6e8d405ca90be3a03d5427c5b24fbd2d68dcc4@linux.intel.com
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs