mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86: dma-mapping: fix broken allocation when dma_mask has been provided
@ 2012-06-13  5:57 Marek Szyprowski
  2012-06-13  7:56 ` Michal Nazarewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Szyprowski @ 2012-06-13  5:57 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Michal Nazarewicz, Marek Szyprowski, Kyungmin Park,
	Thomas Gleixner, Konrad Rzeszutek Wilk, Arnd Bergmann

Commit 0a2b9a6ea93 ("X86: integrate CMA with DMA-mapping subsystem")
broke memory allocation with dma_mask. This patch fixes possible kernel
ops caused by lack of resetting page variable when jumping to 'again' label.

Reported-by: Konrad Rzeszutek Wilk <konrad@darnok.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 arch/x86/kernel/pci-dma.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 62c9457..c0f420f 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -100,7 +100,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
 				 struct dma_attrs *attrs)
 {
 	unsigned long dma_mask;
-	struct page *page = NULL;
+	struct page *page;
 	unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
 	dma_addr_t addr;
 
@@ -108,6 +108,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
 
 	flag |= __GFP_ZERO;
 again:
+	page = NULL;
 	if (!(flag & GFP_ATOMIC))
 		page = dma_alloc_from_contiguous(dev, count, get_order(size));
 	if (!page)
-- 
1.7.1.569.g6f426


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86: dma-mapping: fix broken allocation when dma_mask has been provided
  2012-06-13  5:57 [PATCH] x86: dma-mapping: fix broken allocation when dma_mask has been provided Marek Szyprowski
@ 2012-06-13  7:56 ` Michal Nazarewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Nazarewicz @ 2012-06-13  7:56 UTC (permalink / raw)
  To: x86, linux-kernel, Marek Szyprowski
  Cc: Kyungmin Park, Thomas Gleixner, Konrad Rzeszutek Wilk, Arnd Bergmann

On Wed, 13 Jun 2012 07:57:26 +0200, Marek Szyprowski <m.szyprowski@samsung.com> wrote:

> Commit 0a2b9a6ea93 ("X86: integrate CMA with DMA-mapping subsystem")
> broke memory allocation with dma_mask. This patch fixes possible kernel
> ops caused by lack of resetting page variable when jumping to 'again' label.
>
> Reported-by: Konrad Rzeszutek Wilk <konrad@darnok.org>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  arch/x86/kernel/pci-dma.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
> index 62c9457..c0f420f 100644
> --- a/arch/x86/kernel/pci-dma.c
> +++ b/arch/x86/kernel/pci-dma.c
> @@ -100,7 +100,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
>  				 struct dma_attrs *attrs)
>  {
>  	unsigned long dma_mask;
> -	struct page *page = NULL;
> +	struct page *page;
>  	unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
>  	dma_addr_t addr;
>@@ -108,6 +108,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
> 	flag |= __GFP_ZERO;
>  again:
> +	page = NULL;
>  	if (!(flag & GFP_ATOMIC))
>  		page = dma_alloc_from_contiguous(dev, count, get_order(size));
>  	if (!page)


-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-13  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-13  5:57 [PATCH] x86: dma-mapping: fix broken allocation when dma_mask has been provided Marek Szyprowski
2012-06-13  7:56 ` Michal Nazarewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®