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 3351F3BF31F; Thu, 15 Jan 2026 17:33:03 +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=1768498383; cv=none; b=WX7iPCHQ1SptAGchjA9Wy73RBsYmokScivOMrORvIaKOtBpg1vIx/HrfB0zsmjzVjGrcrzZUJK+tPbQJwAZJ6fSElBLLUshPaE2bssRvhokR2zCJjHfCVbN+uLKPM+cro/DtVLZMTkxHk3dr7qLF+qAP3KplTYtk5Cq+ZcFfSA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498383; c=relaxed/simple; bh=NtReQYVZznkCk4BAg4wNTtjFYLItBYJVt2Q+tHJEWhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RBp9HhX68aenMs6GRlGs5OWrx/S4tZikLRovLlu8Um1Q6J/v0jml9wNjSywdC/xbdn+VqNxzMUr1DSGXrGgQoV9PhDLxKnvMRywKIjokVTaZ8A/tFJv2OSkQtfcRNSEjG1VqiEgBO4lakPod6tzxKbUPuRQFRk3MOnaYHUF1CDM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vgU6G+hF; 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="vgU6G+hF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B34A2C116D0; Thu, 15 Jan 2026 17:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768498383; bh=NtReQYVZznkCk4BAg4wNTtjFYLItBYJVt2Q+tHJEWhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vgU6G+hFLyMe9i31LUt36a5SrB5iX/GZ2GUYuPSr0xokHN4pQjKoEDu9ZJAQamFIh 0xjK4mQkKk77JQLS1XGuKZ5TiZuioQr0PqEInjmpIRYi7YElSNw7cT6Rmwwy0lXZY3 SDCTBDT0h7gYn9e5jjoPY0hSZWp4Mp7W5CQvhInc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, SeongJae Park , Brendan Higgins , David Gow , Kefeng Wang , Andrew Morton Subject: [PATCH 5.15 412/554] mm/damon/tests/vaddr-kunit: handle alloc failures in damon_test_split_evenly_fail() Date: Thu, 15 Jan 2026 17:47:58 +0100 Message-ID: <20260115164301.147612282@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164246.225995385@linuxfoundation.org> References: <20260115164246.225995385@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: SeongJae Park commit 7890e5b5bb6e386155c6e755fe70e0cdcc77f18e upstream. damon_test_split_evenly_fail() 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. Link: https://lkml.kernel.org/r/20251101182021.74868-19-sj@kernel.org Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Signed-off-by: SeongJae Park Cc: Brendan Higgins Cc: David Gow Cc: Kefeng Wang Cc: [5.15+] Signed-off-by: Andrew Morton Signed-off-by: SeongJae Park Signed-off-by: Greg Kroah-Hartman --- mm/damon/vaddr-test.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/mm/damon/vaddr-test.h +++ b/mm/damon/vaddr-test.h @@ -256,7 +256,16 @@ static void damon_test_split_evenly_fail unsigned long start, unsigned long end, unsigned int nr_pieces) { struct damon_target *t = damon_new_target(42); - struct damon_region *r = damon_new_region(start, end); + struct damon_region *r; + + if (!t) + kunit_skip(test, "target alloc fail"); + + r = damon_new_region(start, end); + if (!r) { + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } damon_add_region(r, t); KUNIT_EXPECT_EQ(test,