Re: [PATCH v2 3/3] mm/damon/sysfs: check contexts->nr in repeat_call_fn

From: SeongJae Park

Date: Fri Mar 20 2026 - 20:56:00 EST


On Fri, 20 Mar 2026 16:35:59 +0000 Josh Law <objecting@xxxxxxxxxxxxx> wrote:

> damon_sysfs_repeat_call_fn() calls damon_sysfs_upd_tuned_intervals(),
> damon_sysfs_upd_schemes_stats(), and
> damon_sysfs_upd_schemes_effective_quotas() without checking
> contexts->nr. If nr_contexts is set to 0 via sysfs while DAMON is
> running, these functions dereference contexts_arr[0] and cause a NULL
> pointer dereference. Add the missing check.
>
> Fixes: d809a7c64ba8 ("mm/damon/sysfs: implement refresh_ms file internal work")
> Cc: <stable@xxxxxxxxxxxxxxx> # 6.17.x
> Signed-off-by: Josh Law <objecting@xxxxxxxxxxxxx>
> Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>
> ---

>From the next time, please add patch changelog here.

[...]
Sashiko also added comments [1] that are very same as those for the previous
version of this patch. I replied [2] to those on the thread. In short, nice
findings but orthogonal to this patch, and I will work on those separately.

[1] https://sashiko.dev/#/patchset/20260320163559.178101-3-objecting@xxxxxxxxxxxxx
[2] https://lore.kernel.org/20260320020630.962-1-sj@xxxxxxxxxx


Thanks,
SJ

[...]