From nobody Fri Oct 3 18:03:46 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 025B229D297 for ; Wed, 27 Aug 2025 11:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756295923; cv=none; b=RagkkU6m5mGZcH/mofEmZztIp5N06ElnOT5ZR14q1po3qOjNA7mlYxuiLMIdHpUK3kKzG+fIgFX+sGYzqc/ZjqPfsf5BTC41s7SALehKMs9IxOh8dxU3PU5v2Z1pVggoP3WhKxTNU1/O2GQwb3iA5Ra3coE+qyLWWPybGybItV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756295923; c=relaxed/simple; bh=z9InhMwxlHrlpWLJoWGYpX26uQyPWRXLYtpQgRNMZog=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SpqBzdGSWVLP0xoBKbQBWcHzeob+hhKf0ucoiK61VdjoLvxMgXzPktOiVbkiNSHh1VTGYWnClXV3IU4E9S5Q/+kVJB75rNS1CLz//XIJ6DlDJL/15TEOwWBmxwmGN3mdJ7EGuVp2TYLYwZrl8xuIDOEAwgzNruJTaVNUS3Z/370= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4cBjf354Fyz2VRVq; Wed, 27 Aug 2025 19:55:39 +0800 (CST) Received: from dggpemf200018.china.huawei.com (unknown [7.185.36.31]) by mail.maildlp.com (Postfix) with ESMTPS id D64011A016C; Wed, 27 Aug 2025 19:58:37 +0800 (CST) Received: from huawei.com (10.50.85.135) by dggpemf200018.china.huawei.com (7.185.36.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 27 Aug 2025 19:58:37 +0800 From: Quanmin Yan To: CC: , , , , , , Subject: [PATCH 2/2] mm/damon/reclaim: avoid divide-by-zero in damon_reclaim_apply_parameters() Date: Wed, 27 Aug 2025 19:58:58 +0800 Message-ID: <20250827115858.1186261-3-yanquanmin1@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250827115858.1186261-1-yanquanmin1@huawei.com> References: <20250827115858.1186261-1-yanquanmin1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf200018.china.huawei.com (7.185.36.31) Content-Type: text/plain; charset="utf-8" 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. Fixes: f5a79d7c0c87 ("mm/damon: introduce struct damos_access_pattern") Cc: # 6.1.x Signed-off-by: Quanmin Yan Reviewed-by: SeongJae Park --- mm/damon/reclaim.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 3c71b4596676..fb7c982a0018 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -194,6 +194,11 @@ static int damon_reclaim_apply_parameters(void) if (err) return err; =20 + if (!damon_reclaim_mon_attrs.aggr_interval) { + err =3D -EINVAL; + goto out; + } + err =3D damon_set_attrs(param_ctx, &damon_reclaim_mon_attrs); if (err) goto out; --=20 2.43.0