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 0B53B263C7F; Mon, 13 Apr 2026 16:05:21 +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=1776096321; cv=none; b=VrgLT+Kddy9jkbgSMINJWAf2FiLBL5qS6R7K16HhwmYgTtA2vZscEwMuTzzOAQaCHRnn5sHACNpBunB1UN1F/gK/Yc0vu+U4kEzuaqSCeocUme8eN779gOLv9Au9i1g7EqBQBxRLRCZlyziI1UnhiNfcIp517PlkUClQGFNbX9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776096321; c=relaxed/simple; bh=UFZCr7FqyiGvFIbqHSdkTylRZYkduKrDPr6IaIj7A5M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SoqQov9CSUVUcg+pJjNgVdmOy2NrpZiD57Id9LtsOct1wezj/5uqeZ1Rz7Y35o3JLCu1nG/W8buwCSPARAXuQRholfJtuOO+eN+FYmLeDCHEr3f/bvEhbiVtPjkgyv3vK91Se2zubPrF5w06u7zuXpsE5eZaEnW635imygRwHK4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eS3yvkwI; 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="eS3yvkwI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D206C2BCF6; Mon, 13 Apr 2026 16:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776096320; bh=UFZCr7FqyiGvFIbqHSdkTylRZYkduKrDPr6IaIj7A5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eS3yvkwIJO8bRWrj6jOxtzAcHrjwqBv57Dxdlck7JOS1ngvPvr821zbh9dZJpMRio iMGppA/2m5yC7smuXJN7IYixHGyFpJoYjCyj28c68LypiC0g/U3F00Z5VD0b4U7LQe poWbmp/GIA6OFO/YWzua81y0marOuKvBEUwWeD7g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, SeongJae Park , Andrew Morton Subject: [PATCH 6.19 52/86] mm/damon/sysfs: dealloc repeat_call_control if damon_call() fails Date: Mon, 13 Apr 2026 17:59:59 +0200 Message-ID: <20260413155733.507293769@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155731.568515178@linuxfoundation.org> References: <20260413155731.568515178@linuxfoundation.org> User-Agent: quilt/0.69 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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: SeongJae Park commit 0199390a6b92fc21860e1b858abf525c7e73b956 upstream. damon_call() for repeat_call_control of DAMON_SYSFS could fail if somehow the kdamond is stopped before the damon_call(). It could happen, for example, when te damon context was made for monitroing of a virtual address processes, and the process is terminated immediately, before the damon_call() invocation. In the case, the dyanmically allocated repeat_call_control is not deallocated and leaked. Fix the leak by deallocating the repeat_call_control under the damon_call() failure. This issue is discovered by sashiko [1]. Link: https://lkml.kernel.org/r/20260327003224.55752-1-sj@kernel.org Link: https://lore.kernel.org/20260320020630.962-1-sj@kernel.org [1] Fixes: 04a06b139ec0 ("mm/damon/sysfs: use dynamically allocated repeat mode damon_call_control") Signed-off-by: SeongJae Park Cc: [6.17+] Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/damon/sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1673,7 +1673,8 @@ static int damon_sysfs_turn_damon_on(str repeat_call_control->data = kdamond; repeat_call_control->repeat = true; repeat_call_control->dealloc_on_cancel = true; - damon_call(ctx, repeat_call_control); + if (damon_call(ctx, repeat_call_control)) + kfree(repeat_call_control); return err; }