From nobody Mon Feb 9 00:25:48 2026 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 94CC62FBE0F; Sat, 1 Nov 2025 18:20:37 +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=1762021237; cv=none; b=afV/V5NYEaO+KRTbQBHBBqEt+VYCLA9MVamfH5TreiwBLaqXcZRaJ8Ue9owC0LHWSSoCSzxgZHWBRrhSUn206kRrt9r0tks7PYL0N4arHJsLPkHqa2MKNDWDq5flIlGY3YEj3xN1cPpgmZ8AzoD8/gkHXcA0Jv40W3JWo821IFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021237; c=relaxed/simple; bh=pDU2J5kjF0mDExz6cAUb5XwN43HUszp8OiQLnrE7vDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MyZNTTkdBtgrX+07OIaiLnvY4+aGBdIa9EPsKC17/tvkLtOQe78yMVPpCBl2Dl+gAuQGvdWtrgx7thjafO7KPX/YJSGqVDCzGSv798KdDup0IbV8kE+BdjYPqvBv0PyPrzTfMHb8SeUcOTtTr2pR4o0FnFhS4tua7uZvSMXvkRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tjfWg275; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tjfWg275" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAC60C116B1; Sat, 1 Nov 2025 18:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021237; bh=pDU2J5kjF0mDExz6cAUb5XwN43HUszp8OiQLnrE7vDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tjfWg275qIcqCglMB1pNp6XR9Vg/I76R2wghTcpkgMjU+pMcG/oAyVN63rubsrOU4 66VxNV9bKKV6mHnxcLtqcLvMup9T8H8dBiYozR/dFWadBrMheQ3PgYeKZnFWWWlsMj YuwKb1XkEnqeir/aZOlPZx5tzin/yqHbgWNfYvN4SmccwSkJ2tUu0i5Z5dw5PSac5o XuSWP3jy54dQRj+vUcX7F/KL+0LgDoXvC8AAZsGrh9eB05XnpYevil+X/bXiw96yoK /siThDcrZxIidLTTVVuBC6F1N2MYjM4IyiOXvhSaXO8guTBxf9w2F/hC6qkKrmW31r OBUbclFw8Ehcg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/22] mm/damon/tests/core-kunit: handle memory failure from damon_test_target() Date: Sat, 1 Nov 2025 11:19:57 -0700 Message-ID: <20251101182021.74868-4-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-1-sj@kernel.org> 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 Content-Type: text/plain; charset="utf-8" damon_test_target() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index a2c9ee7a5de1..6e8a605277a3 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -58,7 +58,14 @@ static void damon_test_target(struct kunit *test) struct damon_ctx *c =3D damon_new_ctx(); struct damon_target *t; =20 + if (!c) + kunit_skip(test, "ctx alloc fail"); + t =3D damon_new_target(); + if (!t) { + damon_destroy_ctx(c); + kunit_skip(test, "target alloc fail"); + } KUNIT_EXPECT_EQ(test, 0u, nr_damon_targets(c)); =20 damon_add_target(c, t); --=20 2.47.3