mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: cgel.zte@gmail.com
To: dave.hansen@linux.intel.com
Cc: luto@kernel.org, peterz@infradead.org, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com,
	jan.kiszka@siemens.com, jmoyer@redhat.com,
	dan.j.williams@intel.com, neilb@suse.de, yang.guang5@zte.com.cn,
	linux-kernel@vger.kernel.org
Subject: [PATCH] Modify the check condition
Date: Sat, 18 Sep 2021 06:52:32 +0000	[thread overview]
Message-ID: <20210918065232.239336-1-yang.guang5@zte.com.cn> (raw)

From: Yang Guang <yang.guang5@zte.com.cn>

The vma may be NULL, and accessing the member of vma like "vma->vm_start"
in calling follow_phys may occur segmentation fault.
So it should check vma at beginning. If vma is null, it will return. And
the if condition won't execute "vm->vm_flags".

Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 arch/x86/mm/pat/memtype.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index 4ba2a3ee4bce..b7108b37b754 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -1089,7 +1089,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,
 	resource_size_t paddr;
 	unsigned long prot;
 
-	if (vma && !(vma->vm_flags & VM_PAT))
+	if (!(vma) || !(vma->vm_flags & VM_PAT))
 		return;
 
 	/* free the chunk starting from pfn or the whole chunk */
-- 
2.25.1


             reply	other threads:[~2021-09-18  6:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-18  6:52 cgel.zte [this message]
2021-09-18  8:31 ` Peter Zijlstra
  -- strict thread matches above, loose matches on Subject: below --
2021-09-18  6:15 cgel.zte

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=20210918065232.239336-1-yang.guang5@zte.com.cn \
    --to=cgel.zte@gmail.com \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=neilb@suse.de \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yang.guang5@zte.com.cn \
    /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®