mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
mm/damon/core: add damon_new_region() debug_sanity check
damon_new_region() is supposed to be called with only valid address range arguments. Do the check under DAMON_DEBUG_SANITY. Link: https://lkml.kernel.org/r/20260306152914.86303-3-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Brendan Higgins <brendan.higgins@linux.dev> Cc: David Gow <davidgow@google.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
62f0582875
commit
b0264a951c
|
|
@ -109,6 +109,17 @@ int damon_select_ops(struct damon_ctx *ctx, enum damon_ops_id id)
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DAMON_DEBUG_SANITY
|
||||
static void damon_verify_new_region(unsigned long start, unsigned long end)
|
||||
{
|
||||
WARN_ONCE(start >= end, "start %lu >= end %lu\n", start, end);
|
||||
}
|
||||
#else
|
||||
static void damon_verify_new_region(unsigned long start, unsigned long end)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Construct a damon_region struct
|
||||
*
|
||||
|
|
@ -118,6 +129,7 @@ struct damon_region *damon_new_region(unsigned long start, unsigned long end)
|
|||
{
|
||||
struct damon_region *region;
|
||||
|
||||
damon_verify_new_region(start, end);
|
||||
region = kmem_cache_alloc(damon_region_cache, GFP_KERNEL);
|
||||
if (!region)
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user