mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
To: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Subject: [PATCH] mm/khugepaged: fix a tracepoint for error cases
Date: Tue,  1 Apr 2025 16:23:53 -0400	[thread overview]
Message-ID: <20250401202354.103501-2-sweettea-kernel@dorminy.me> (raw)

Fix a potential NULL pointer dereference in trace_mm_khugepaged_scan_pmd()
when folio is NULL. This is possible if vm_normal_page() returned a NULL
page -- which is unlikely, but was hit in testing.

(The tracepoint in include/trace/events/huge_memory.h can already deal
with a NULL page.)

Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>

---
Based on akpm/mm-unstable.

 mm/khugepaged.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index cc945c6ab3bd..eb7b019159d4 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1435,8 +1435,9 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
 		*mmap_locked = false;
 	}
 out:
-	trace_mm_khugepaged_scan_pmd(mm, &folio->page, writable, referenced,
-				     none_or_zero, result, unmapped);
+	trace_mm_khugepaged_scan_pmd(mm, folio ? &folio->page : NULL,
+				     writable, referenced, none_or_zero,
+				     result, unmapped);
 	return result;
 }
 

base-commit: e026356e4192ff5a52c1d535e6b9e3fa50def2c4
-- 
2.48.1


             reply	other threads:[~2025-04-01 20:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 20:23 Sweet Tea Dorminy [this message]
2025-04-01 21:09 ` Andrew Morton

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=20250401202354.103501-2-sweettea-kernel@dorminy.me \
    --to=sweettea-kernel@dorminy.me \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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®