* [PATCH] lib/test_hmm: fix NULL deref and wrong direction in devmem fault debug message
@ 2026-08-11 9:22 liuqiangneo
2026-08-12 1:24 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: liuqiangneo @ 2026-08-11 9:22 UTC (permalink / raw)
To: jgg, leon, akpm; +Cc: linux-mm, linux-kernel, Qiang Liu
From: Qiang Liu <liuqiang@kylinos.cn>
Move pr_debug() inside the `if (dpage)` block to avoid a NULL deref,
and fix the direction label from "sys to dev" to "dev to sys" to match
the device-to-system copy.
Assisted-by: Qoder:Qwen-3.8-MAX-Preview
Signed-off-by: Qiang Liu <liuqiang@kylinos.cn>
---
lib/test_hmm.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 6e72a0d8a53d..1dae93ab1e93 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -1151,10 +1151,9 @@ static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args,
if (!dpage && !order)
return VM_FAULT_OOM;
- pr_debug("migrating from sys to dev pfn src: 0x%lx pfn dst: 0x%lx\n",
- page_to_pfn(spage), page_to_pfn(dpage));
-
if (dpage) {
+ pr_debug("migrating from dev to sys pfn src: 0x%lx pfn dst: 0x%lx\n",
+ page_to_pfn(spage), page_to_pfn(dpage));
lock_page(dpage);
*dst |= migrate_pfn(page_to_pfn(dpage));
}
--
2.43.0
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/test_hmm: fix NULL deref and wrong direction in devmem fault debug message
2026-08-11 9:22 [PATCH] lib/test_hmm: fix NULL deref and wrong direction in devmem fault debug message liuqiangneo
@ 2026-08-12 1:24 ` Andrew Morton
2026-08-12 9:33 ` 刘强
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2026-08-12 1:24 UTC (permalink / raw)
To: liuqiangneo; +Cc: jgg, leon, linux-mm, linux-kernel, Qiang Liu
On Tue, 11 Aug 2026 17:22:55 +0800 liuqiangneo@163.com wrote:
> From: Qiang Liu <liuqiang@kylinos.cn>
>
> Move pr_debug() inside the `if (dpage)` block to avoid a NULL deref,
> and fix the direction label from "sys to dev" to "dev to sys" to match
> the device-to-system copy.
>
> ...
>
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -1151,10 +1151,9 @@ static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args,
> if (!dpage && !order)
> return VM_FAULT_OOM;
>
> - pr_debug("migrating from sys to dev pfn src: 0x%lx pfn dst: 0x%lx\n",
> - page_to_pfn(spage), page_to_pfn(dpage));
> -
> if (dpage) {
> + pr_debug("migrating from dev to sys pfn src: 0x%lx pfn dst: 0x%lx\n",
> + page_to_pfn(spage), page_to_pfn(dpage));
> lock_page(dpage);
> *dst |= migrate_pfn(page_to_pfn(dpage));
> }
Current kernel code doesn't look like this?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re:Re: [PATCH] lib/test_hmm: fix NULL deref and wrong direction in devmem fault debug message
2026-08-12 1:24 ` Andrew Morton
@ 2026-08-12 9:33 ` 刘强
0 siblings, 0 replies; 3+ messages in thread
From: 刘强 @ 2026-08-12 9:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: jgg, leon, linux-mm, linux-kernel, Qiang Liu
[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]
Hi Andrew,
Thanks for taking a look.
Sorry, the previous version was based on mm-everything.
I've now rebased onto mm-new and resent as v2.
I compared against
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/log/?h=mm-new
and the code matches the patch context.
v2:https://lore.kernel.org/all/20260812092856.55296-1-liuqiangneo@163.com/
--
Thanks
Best Regards
Qiang
At 2026-08-12 09:24:40, "Andrew Morton" <akpm@linux-foundation.org> wrote:
>On Tue, 11 Aug 2026 17:22:55 +0800 liuqiangneo@163.com wrote:
>
>> From: Qiang Liu <liuqiang@kylinos.cn>
>>
>> Move pr_debug() inside the `if (dpage)` block to avoid a NULL deref,
>> and fix the direction label from "sys to dev" to "dev to sys" to match
>> the device-to-system copy.
>>
>> ...
>>
>> --- a/lib/test_hmm.c
>> +++ b/lib/test_hmm.c
>> @@ -1151,10 +1151,9 @@ static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args,
>> if (!dpage && !order)
>> return VM_FAULT_OOM;
>>
>> - pr_debug("migrating from sys to dev pfn src: 0x%lx pfn dst: 0x%lx\n",
>> - page_to_pfn(spage), page_to_pfn(dpage));
>> -
>> if (dpage) {
>> + pr_debug("migrating from dev to sys pfn src: 0x%lx pfn dst: 0x%lx\n",
>> + page_to_pfn(spage), page_to_pfn(dpage));
>> lock_page(dpage);
>> *dst |= migrate_pfn(page_to_pfn(dpage));
>> }
>
>Current kernel code doesn't look like this?
[-- Attachment #2: Type: text/html, Size: 2799 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-12 9:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 9:22 [PATCH] lib/test_hmm: fix NULL deref and wrong direction in devmem fault debug message liuqiangneo
2026-08-12 1:24 ` Andrew Morton
2026-08-12 9:33 ` 刘强
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox