From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C43A432BC1B; Wed, 17 Sep 2025 12:52:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758113539; cv=none; b=fZSLA1IJZpvu8CJncZcVqoMU/ioo6j1+LJpUEwxVHmuFGP9HpsR78AeqUXj1PNktujE9Qdqwnm5FakNMMlQpA3eEqbzPRKcSPBdLodIgkd6U8gWafIydZ5q+9LkZ3gBXeH4aJSrXECh4G5vrp6wBZvlEGm4MSKBUaVPT28KmqU4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758113539; c=relaxed/simple; bh=v3qDzks2CY5t87xIEUQyl4C1mfRqI0RerTFJcFNu2BU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PM1FKnSHRftA0tSxlGuY6sm0QjHPkQq8LBYQtEy+sBzbucnhUcUTcJAVD1gfT27sQNHUZwfCOBwRCqMWgIT8592T0igQ2naEiKVFCokuawG4Due/xMRy32zpPL8JbufTSoNOmvs6V2njbtTwr5RWQ8A9lWz031unDUH0IrzFHSw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vYcs2KPo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vYcs2KPo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15532C4CEF7; Wed, 17 Sep 2025 12:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1758113539; bh=v3qDzks2CY5t87xIEUQyl4C1mfRqI0RerTFJcFNu2BU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vYcs2KPowkY+FPGZ6dJmBUaBjyKN2yZXEtBs7Bc6L5yRp+oD4Wb81OGLS4NoOapg9 iwXlq2IM8JkDf02mYmkhwvTyAUH7p50fVsMeTOCasRDKF5sS5XKW9h6aPmFRrrxj8u /3vfe61J77WbUwCueRY0eRZzQ3jeMnfLyCzbo/kE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Quanmin Yan , SeongJae Park , Kefeng Wang , ze zuo , Andrew Morton Subject: [PATCH 6.12 080/140] mm/damon/reclaim: avoid divide-by-zero in damon_reclaim_apply_parameters() Date: Wed, 17 Sep 2025 14:34:12 +0200 Message-ID: <20250917123346.265991606@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250917123344.315037637@linuxfoundation.org> References: <20250917123344.315037637@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Quanmin Yan commit e6b543ca9806d7bced863f43020e016ee996c057 upstream. 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/20250827115858.1186261-3-yanquanmin1@huawei.com Fixes: f5a79d7c0c87 ("mm/damon: introduce struct damos_access_pattern") Signed-off-by: Quanmin Yan Reviewed-by: SeongJae Park Cc: Kefeng Wang Cc: ze zuo Cc: [6.1+] Signed-off-by: Andrew Morton Signed-off-by: SeongJae Park Signed-off-by: Greg Kroah-Hartman --- mm/damon/reclaim.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -194,6 +194,11 @@ static int damon_reclaim_apply_parameter if (err) return err; + if (!damon_reclaim_mon_attrs.aggr_interval) { + err = -EINVAL; + goto out; + } + err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); if (err) goto out;