Skip to content

Commit e6b543c

Browse files
Quanmin Yanakpm00
authored andcommitted
mm/damon/reclaim: avoid divide-by-zero in damon_reclaim_apply_parameters()
When creating a new scheme of DAMON_RECLAIM, the calculation of 'min_age_region' uses 'aggr_interval' as the divisor, which may lead to division-by-zero errors. Fix it by directly returning -EINVAL when such a case occurs. Link: https://lkml.kernel.org/r/[email protected] Fixes: f5a79d7 ("mm/damon: introduce struct damos_access_pattern") Signed-off-by: Quanmin Yan <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: ze zuo <[email protected]> Cc: <[email protected]> [6.1+] Signed-off-by: Andrew Morton <[email protected]>
1 parent 711f19d commit e6b543c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mm/damon/reclaim.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ static int damon_reclaim_apply_parameters(void)
194194
if (err)
195195
return err;
196196

197+
if (!damon_reclaim_mon_attrs.aggr_interval) {
198+
err = -EINVAL;
199+
goto out;
200+
}
201+
197202
err = damon_set_attrs(param_ctx, &damon_reclaim_mon_attrs);
198203
if (err)
199204
goto out;

0 commit comments

Comments
 (0)