Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/kmemleak: use PF_KTHREAD flag to detect kernel threads

Replace the current->mm check with PF_KTHREAD flag for more reliable
kernel thread detection in scan_should_stop(). The PF_KTHREAD flag is the
standard way to identify kernel threads and is not affected by temporary
mm borrowing via kthread_use_mm() (although kmemleak does not currently
encounter such cases, this makes the code more robust).

No functional change.

Link: https://lkml.kernel.org/r/20260130093729.2045858-3-zhongqiu.han@oss.qualcomm.com
Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Zhongqiu Han and committed by
Andrew Morton
c2d91965 fc9ef297

+3 -3
+3 -3
mm/kmemleak.c
··· 1505 1505 * This function may be called from either process or kthread context, 1506 1506 * hence the need to check for both stop conditions. 1507 1507 */ 1508 - if (current->mm) 1509 - return signal_pending(current); 1508 + if (current->flags & PF_KTHREAD) 1509 + return kthread_should_stop(); 1510 1510 1511 - return kthread_should_stop(); 1511 + return signal_pending(current); 1512 1512 } 1513 1513 1514 1514 /*