mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: yangge1116@126.com
To: m.szyprowski@samsung.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, robin.murphy@arm.com, hch@lst.de,
	liuzixing@hygon.cn, Ge Yang <yangge1116@126.com>
Subject: [PATCH] dma-direct: fix type mismatch in dma_direct_alloc_pages
Date: Fri, 14 Aug 2026 14:30:00 +0800	[thread overview]
Message-ID: <1786689000-14677-1-git-send-email-yangge1116@126.com> (raw)

From: Ge Yang <yangge1116@126.com>

The pool allocation path directly returned the void* cpu virtual
address from dma_direct_alloc_from_pool(), which is type‑mismatched
against struct page *. Convert the dma_handle to page via
dma_direct_to_page() instead.

Fixes: 5b138c534fda ("dma-direct: factor out a dma_direct_alloc_from_pool helper")
Signed-off-by: Ge Yang <yangge1116@126.com>
Cc: stable@vger.kernel.org
---
 kernel/dma/direct.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 4391b79..f496568 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -356,8 +356,12 @@ struct page *dma_direct_alloc_pages(struct device *dev, size_t size,
 	struct page *page;
 	void *ret;
 
-	if (force_dma_unencrypted(dev) && dma_direct_use_pool(dev, gfp))
-		return dma_direct_alloc_from_pool(dev, size, dma_handle, gfp);
+	if (force_dma_unencrypted(dev) && dma_direct_use_pool(dev, gfp)) {
+		ret = dma_direct_alloc_from_pool(dev, size, dma_handle, gfp);
+		if (!ret)
+			return NULL;
+		return dma_direct_to_page(dev, *dma_handle);
+	}
 
 	page = __dma_direct_alloc_pages(dev, size, gfp, false);
 	if (!page)
-- 
2.7.4


             reply	other threads:[~2026-08-14  6:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260814063037eucas1p13a146c907bec7280bb28d9e8ef009eae@eucas1p1.samsung.com>
2026-08-14  6:30 ` yangge1116 [this message]
2026-08-14  7:11   ` Marek Szyprowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1786689000-14677-1-git-send-email-yangge1116@126.com \
    --to=yangge1116@126.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuzixing@hygon.cn \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®