Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1255684

[tip:x86/urgent] x86/dma-mapping: Fix arch_dma_alloc_attrs() oops with NULL dev

From "tip-bot for Ville Syrjälä" <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:x86/urgent] x86/dma-mapping: Fix arch_dma_alloc_attrs() oops with NULL dev
Date 2015-10-26 07:10 +0100
Message-ID <qnJ8J-4Gh-7@gated-at.bofh.it> (permalink)
References <qnARP-814-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  298a96c12b2d8fd845ae0c2c21c0a1c0b470f99e
Gitweb:     http://git.kernel.org/tip/298a96c12b2d8fd845ae0c2c21c0a1c0b470f99e
Author:     Ville Syrjälä <ville.syrjala@linux.intel.com>
AuthorDate: Sun, 25 Oct 2015 23:11:43 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 26 Oct 2015 14:59:36 +0900

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 <mroos@linux.ee>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Link: http://lkml.kernel.org/r/1445807503-8920-1-git-send-email-ville.syrjala@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/pci-dma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 1b55de1..cd99433 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -131,11 +131,12 @@ void dma_generic_free_coherent(struct device *dev, size_t size, void *vaddr,
 
 bool arch_dma_alloc_attrs(struct device **dev, gfp_t *gfp)
 {
+	if (!*dev)
+		*dev = &x86_dma_fallback_dev;
+
 	*gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
 	*gfp = dma_alloc_coherent_gfp_flags(*dev, *gfp);
 
-	if (!*dev)
-		*dev = &x86_dma_fallback_dev;
 	if (!is_device_dma_capable(*dev))
 		return false;
 	return true;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] x86: dma-mapping: Fix arch_dma_alloc_attrs() oops with NULL dev ville.syrjala@linux.intel.com - 2015-10-25 22:20 +0100
  Re: [PATCH] x86: dma-mapping: Fix arch_dma_alloc_attrs() oops with  NULL dev Meelis Roos <mroos@linux.ee> - 2015-10-25 22:50 +0100
  [tip:x86/urgent] x86/dma-mapping: Fix arch_dma_alloc_attrs()   oops with NULL dev "tip-bot for Ville Syrjälä" <tipbot@zytor.com> - 2015-10-26 07:10 +0100

csiph-web