From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B5082BE034 for ; Wed, 12 Aug 2026 01:24:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786497882; cv=none; b=DB73asH925cyBETuoktaSWjZpo0cGuLUvRf3UljkxWWBAf3h5nYR76MoD3Oa1DgHSEzHrwWdFRMypKbLP9uQDxMcSBLiLwoJfLi8MB/dQeWojYwNFrZLgrazSWsauw/Nwkup6oH/7ewjgat1dAe8T/xzSFddVECXm73NBFOW+ds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786497882; c=relaxed/simple; bh=RHXzaQvs4y0LFKUpVyjk+kt6XCpGMp0eiSSDzE9d45I=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=gyNXcwsRDkfv34srwX5pT4aaOvBrB8KkEyQsAu3OD6d1OEQapat9vsaV9AH9enC2HChf7wOilA1QpOlA9sac+jk8N47P7gGFRc+0Ui/sXZWrXYhIVQSliAsDvdQ+x8wiAtlUUWtmPAi2ZKhusZyAiuwqVqciC2VIUnamTc/DJTM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=CyMw8fYN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="CyMw8fYN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA4F61F000E9; Wed, 12 Aug 2026 01:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786497881; bh=l5+IacHwrKkXrPidsTQCEFGfOBMjs+caiTHLJljiYRk=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=CyMw8fYNQBJp7PvVipyqLIow88k30YpmfjAx+g3UxhS49uqcj5vf9IEjLbiXKdCYI QLywYhTO9jAX6EPcTbqBuXz0o09X5WCZstC1XcqqRhfOAz+5u5PjSLZyJOtNlD+rO9 kxX+hdazlRQdCqoamobuN4G4Zv3FAc70cp4r1T/g= Date: Tue, 11 Aug 2026 18:24:40 -0700 From: Andrew Morton To: liuqiangneo@163.com Cc: jgg@ziepe.ca, leon@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qiang Liu Subject: Re: [PATCH] lib/test_hmm: fix NULL deref and wrong direction in devmem fault debug message Message-Id: <20260811182440.79cf147171dc7f87762a949d@linux-foundation.org> In-Reply-To: <20260811092256.102101-1-liuqiangneo@163.com> References: <20260811092256.102101-1-liuqiangneo@163.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 11 Aug 2026 17:22:55 +0800 liuqiangneo@163.com wrote: > From: Qiang Liu > > 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?