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 AC5BD33B6ED; Fri, 9 Jan 2026 12:48: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=1767962883; cv=none; b=I2P98Dtb6e+28WBzfOIlWhaeHQldDIqXiNI36qG0tHc0rp6zCMulOCCOXzuu4yBxxNkUsEWKwI8Li36sZjW6IF4K8lBL49MdG2VoLdBCEPVhFNzQ2hvGLvYgbFAyP2PxCyR78PFp3CoBYeSCRxaXYFstt0vEdFAhqatijEu7oWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767962883; c=relaxed/simple; bh=lRearEmFbceH1pcAGtkeWTpccM/okhkei/iirfPY+8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S5IBc+XH5CZ4rGXkkGPpObLLTF1ax3ll7Rn6za1ybgyMW2NjJsrXXR1uvLvs64S1ge/HpXikPt0V++tkkWlRWfXbf6W/I5zNa1q3YW+bhwP0UDWiKtlJVjhMx5TMphSP71Cjfsb2abJjFqJ8b8Yu6VCtr/RjsLNLtVdGAK8yf2Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=G//W2zv1; 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="G//W2zv1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38F0DC4CEF1; Fri, 9 Jan 2026 12:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767962883; bh=lRearEmFbceH1pcAGtkeWTpccM/okhkei/iirfPY+8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G//W2zv1fFKyf9u6lmmYcpyW+wYCZEqZ45ZuenHYzqTaBNbFBCKS1LF3lYi3C+jFD FO10k+Ji3kf4B1UOoA9p7CMPVxGUZc3N8Jl0iFbxBIeoc5G4CvEwRzkCtaf3le64SP 3m9njp56vyxFS4oHbyDd+g/Y/6/Y62vQEA5UJIYc= 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 6.1 520/634] mm/damon/tests/core-kunit: handle alloc failures on dasmon_test_merge_regions_of() Date: Fri, 9 Jan 2026 12:43:18 +0100 Message-ID: <20260109112137.127444631@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112117.407257400@linuxfoundation.org> References: <20260109112117.407257400@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: SeongJae Park commit 0998d2757218771c59d5ca59ccf13d1542a38f17 upstream. damon_test_merge_regions_of() 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-8-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: Greg Kroah-Hartman --- mm/damon/core-test.h | 6 ++++++ 1 file changed, 6 insertions(+) --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -210,8 +210,14 @@ static void damon_test_merge_regions_of( int i; t = damon_new_target(); + if (!t) + kunit_skip(test, "target alloc fail"); for (i = 0; i < ARRAY_SIZE(sa); i++) { r = damon_new_region(sa[i], ea[i]); + if (!r) { + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } r->nr_accesses = nrs[i]; damon_add_region(r, t); }