Re:Re: [PATCH] lib/test_hmm: fix NULL deref and wrong direction in devmem fault debug message
刘强 <[email protected]>
| Newsgroups | org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
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/[email protected]/ -- Thanks Best Regards Qiang At 2026-08-12 09:24:40, "Andrew Morton" <[email protected]> wrote: >On Tue, 11 Aug 2026 17:22:55 +0800 [email protected] wrote: > >> From: Qiang Liu <[email protected]> >> >> 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?