Message ID | 20241222231222.85060-2-sj@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEBFBE7718E for <linux-mm@archiver.kernel.org>; Sun, 22 Dec 2024 23:12:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61B506B0082; Sun, 22 Dec 2024 18:12:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CB286B0083; Sun, 22 Dec 2024 18:12:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 491E76B0088; Sun, 22 Dec 2024 18:12:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2BB786B0082 for <linux-mm@kvack.org>; Sun, 22 Dec 2024 18:12:29 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D1053C086E for <linux-mm@kvack.org>; Sun, 22 Dec 2024 23:12:28 +0000 (UTC) X-FDA: 82924144884.26.433221F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 1991440009 for <linux-mm@kvack.org>; Sun, 22 Dec 2024 23:11:52 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W0ggchTu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734909129; a=rsa-sha256; cv=none; b=qTYmVvndfLSfV/iWvZ1yQ0hm5Xh27e0yb46OGPcw/Dmp/jAeiIC5kVom8sTsN9R2r923xl np8AJF4mGDJowf+MMoBIca8Ntma0vxKBH6z43EVeN7gTwJJ6N8K1ZhOUoRJqVFk0IMiNeg q9uctS+0vciB0zYU6hoyr2LmgnsZ0pk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W0ggchTu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734909129; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jhxMfnOQ7sl2nzCsHRQYC+OB6MWPAHABIHNQ0teeV5U=; b=kTQRQJ08NR4Bzunj1kjeUuAnata9pQKUmBHpHOUwyL/fXILZJ2PVuwo4Laj8RUTj2XXBfv zUYhHPAoC7gktAuQYSKQsb072PJ2jhQUp7FbOTegpvtrKD/IoiZ9p+qV2ZOI/+t1hnRtkg cNjPEVXAFyrgtTqZSKlOYvMcjJMs9UY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4CD915C5446; Sun, 22 Dec 2024 23:11:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE365C4CECD; Sun, 22 Dec 2024 23:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734909145; bh=zvpnzpnU6SEsn/lS2CcE/GaMIrv4lRmkiTD51TF9JK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0ggchTuurFk/4bVT7d6P1pbWuYieEKHqJaICN3aHGVUWNzUSjiNo4BsPlE/RH3XW SQ4lp2SVVQukk9ETBPKbEDXe0C/PCNAJtMKrWn/3/bmx0cKfb69pPjJFDn0XOeM8P+ vfn9XMjpaxNpgVNE46SBYchgHg8Ew1XLDnm5/rsavJfY+rth5hrdKLEEdoZksys22V 3h+SqDrUMFjwElMOKgkBdysVpScq3CiOe10FMBw1mSsNHtoAGIfgFFDeOexYUpGIhk XROXbwrjhj+apd1SrSGKONqcxQXNC6J+92mZ5lF7tu6Yspy0zUuE6lEppy1OI4pYvN zL/84F2RZR10A== From: SeongJae Park <sj@kernel.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: SeongJae Park <sj@kernel.org>, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] mm/damon/core: fix new damon_target objects leaks on damon_commit_targets() Date: Sun, 22 Dec 2024 15:12:21 -0800 Message-Id: <20241222231222.85060-2-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241222231222.85060-1-sj@kernel.org> References: <20241222231222.85060-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1991440009 X-Stat-Signature: 5bogk43dcrdpaua1w334u49rai4yokj1 X-HE-Tag: 1734909112-728244 X-HE-Meta: U2FsdGVkX19e4KR0CeEezUrsLlZuSKnlWGuUufYm8B9e8COYxn4ONL7MUu/HBaSXvzubQ/D2bHWYebdk6wNm44M13c9G+zInB0088jflrJDhnDCH8ivlds93DYMRKxsAJQb9L75vMENSu9F8EcWvV6W6XI6HxpMEEM/CnYKJo3N3A+6wM7BcED0ilBwcEZIwjdzLkOsNiDzGGWkBtVW4HLk2ugN01cIhiNJ/8VKceCxp6G8vjzmoNkowFGiu8VyHx8PUHMYcFIl42/ayx7lt/gF5uY7+Pc+DGQ7n98mOi6XLENsgum/cTiq9sXTuKmlVTqZVAPpy5IA4ovjwbzH5AqbGy10XLJepd2Ba+i+4V33e+BCqEs77uTEASA7ebAXHpHXEzUjctOHmS4wAKgghuFcJV7A5pA3UIpON60o5u7oEZRl81VNkm49yPyhbZQdtoUij3yj6NW0RjGZ66Y46/zwgyl1Ou+nA/NGY80QEQ0ROXtXUPlnGIociZv3Gm3/MMDfFsKH8Nx3fg9KKfgCzRKikH8C9N4j60jrfsk5OmXDVJHHs3qQMU0lpuKlqeaJa6DNcPGm5C31Zs8l/w+ggqBQEAGr3ry5i9F9KT5HFw6SLxrqvGC6gEXwTJfU3vZ+4hCyJQIHrYJTyNvXA+40cNSo0oZl+SLRe6+kP/OrlK2rEsb257dIh+gaP/3Ex1ac0lQNONynzYSFx03aO+9OQRzk5SwE4SXodl8kc1NEY7BlJ9wrRIBZ2LFkTocWSg8p169OWeAinailZP+0z7JC2zBpjtbS+npbiBYZ6denOSSO9C1TEMMjo3Y2NmTp8zn/ERIDwxysGfWnNcV2WoKAyQJzaye03CJoCjaZ3DLv1Qfx9xZwQUyANndAE5OC6XGMtaIDEm0/TRs5RqBGBxLeWK0sZ+JkKODd3SUy2+eVytg0WKyBRF/Qp9JdpP+ceoczPw1w4vLt0twNRNi1qhSD lVIQqykb QZZQcthLQRjFOQs61FVHMbPh925gJWx6PiZT/bX78dhASqGeHs9LwfxKA78uEgtRn+ulfbrbrcJ1ln2ig6iBV8p9lxSsLHAGZ2OGZdsnOsMswScXu0o/bQ+dv8sYdVFnTqkH+ceJ1gbBUjL8LDuq4S35/DnRps7YY0VgSriY5iBeEuC98P3nLNk51IIsE+isMHWTtDCpZJUduoDg9U4nX9pNoG2r4ULVW6xbXfDCNoKvSrNstyAzxE1nwSsuYK0h7BB5VmKL4LDQaiNh4uxY6Q+FT2Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm/damon/core: fix memory leaks and ignored inputs from damon_commit_ctx()
|
expand
|
diff --git a/mm/damon/core.c b/mm/damon/core.c index a71703e05300..931e8e4b1333 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -961,8 +961,11 @@ static int damon_commit_targets( return -ENOMEM; err = damon_commit_target(new_target, false, src_target, damon_target_has_pid(src)); - if (err) + if (err) { + damon_destroy_target(new_target); return err; + } + damon_add_target(dst, new_target); } return 0; }
When new DAMON targets are added via damon_commit_targets(), the newly created targets are not deallocated when updating the internal data (damon_commit_target()) is failed. Worse yet, even if the setup is successfully done, the new target is not linked to the context. Hence, the new targets are always leaked regardless of the internal data setup failure. Fix the leaks. Fixes: 9cb3d0b9dfce ("mm/damon/core: implement DAMON context commit function") Cc: <stable@vger.kernel.org> Signed-off-by: SeongJae Park <sj@kernel.org> --- mm/damon/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)