All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: yahia <yahia.a.abdrabou@gmail.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 1/2] mm/damon/reclaim: fix destruction of ctx
Date: Fri, 19 Jun 2026 23:51:40 +0000	[thread overview]
Message-ID: <20260619235140.9DDEC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260619234606.221163-2-yahia.a.abdrabou@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch introduces a memory leak of the temporary DAMON context (param_ctx) and its associated structures on the success path of parameter application.
--

commit 57dd2b9f42514d0ee1c739cb34a24c15b5d98865
Author: yahia ahmed <yahia.a.abdrabou@gmail.com>

mm/damon/reclaim: fix destruction of ctx

This commit attempts to fix what is perceived as an early destruction of
the DAMON context by returning directly on success.

> diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
> index ce4499cf4b8b0..15bc06ae75053 100644
> --- a/mm/damon/reclaim.c
> +++ b/mm/damon/reclaim.c
> @@ -268,6 +268,9 @@ static int damon_reclaim_apply_parameters(void)
>  	if (err)
>  		goto out;
>  	err = damon_commit_ctx(ctx, param_ctx);
> +
> +	if (!err)
> +		return 0;

[Severity: High]
Does this early return cause a memory leak of the temporary context?

In damon_reclaim_apply_parameters(), param_ctx is allocated as a temporary
context to construct new targets, schemes, quotas, and filters. The call
to damon_commit_ctx() duplicates these structures into the global context
rather than taking ownership of the pointers.

Because param_ctx is temporary and its contents are copied, it needs to be
destroyed unconditionally. Skipping damon_destroy_ctx(param_ctx) on the
success path leaves the temporary param_ctx and all its attached structures
leaked on every successful parameter application.

>  out:
>  	damon_destroy_ctx(param_ctx);
>  	return err;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260619234606.221163-1-yahia.a.abdrabou@gmail.com?part=1

  reply	other threads:[~2026-06-19 23:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19 23:46 [PATCH 0/2] mm/damon/reclaim: fix initalization and parameter issues yahia
2026-06-19 23:46 ` [PATCH 1/2] mm/damon/reclaim: fix destruction of ctx yahia
2026-06-19 23:51   ` sashiko-bot [this message]
2026-06-19 23:46 ` [PATCH 2/2] mm/damon/reclaim: fix potential memory leak yahia
2026-06-19 23:56   ` sashiko-bot
2026-06-20  0:26 ` [PATCH 0/2] mm/damon/reclaim: fix initalization and parameter issues SeongJae Park
2026-06-20  0:35   ` [PATCH v2 0/1] fix initialization " yahia
2026-06-20  0:35     ` [PATCH v2 1/1] mm/damon/reclaim: fix potential memory leak yahia
2026-06-20  2:48       ` sashiko-bot
2026-06-20  3:29       ` [PATCH v3] " yahia
2026-06-20 16:40         ` SeongJae Park
2026-06-20 16:50           ` [PATCH v1] " yahia
2026-06-20 17:09             ` SeongJae Park
2026-06-20 17:20               ` yahia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260619235140.9DDEC1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yahia.a.abdrabou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.