DAMON development mailing list
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [RFC PATCH v2 3/8] mm/damon/ops-common: support hugepage_size damon filter matching
Date: Mon, 14 Sep 2026 08:17:44 -0700	[thread overview]
Message-ID: <20260914151746.98049-1-sj@kernel.org> (raw)
In-Reply-To: <20260914145936.B4E2F1F008A2@smtp.kernel.org>

On Mon, 14 Sep 2026 14:59:36 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Memory leak of newly allocated filter when HUGEPAGE_SIZE range is invalid.
> --
> 
> commit 5ea2818b5d3def212dc5a08d79877c1ebf66bd6e
> Author: SJ Park <sj@kernel.org>
> 
> mm/damon/ops-common: support hugepage_size damon filter matching
> 
> Update ops-common data attribute filter matching logic to support
> hugepage_size filter type.
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 0c98f7e267d07..ecfe99450e5f0 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> [ ... ]
> > @@ -1838,6 +1848,12 @@ static int damon_commit_filters(struct damon_probe *dst,
> >  		case DAMON_FILTER_TYPE_MEMCG:
> >  			new_filter->memcg_id = src_filter->memcg_id;
> >  			break;
> > +		case DAMON_FILTER_TYPE_HUGEPAGE_SIZE:
> > +			if (src_filter->range_max < src_filter->range_min)
> > +				return -EINVAL;
> 
> [Severity: Medium]
> Does this return path leak new_filter?
> 
> When src_filter->range_max < src_filter->range_min evaluates to true
> in damon_commit_filters(), the function returns -EINVAL immediately.
> 
> Since new_filter was already allocated earlier in the loop:
> 
>         new_filter = damon_new_filter(src_filter->type,
>                         src_filter->matching, src_filter->allow);
>         if (!new_filter)
>                 return -ENOMEM;
> 
> and has not yet been added to the probe's filter list or freed before
> this return, does this drop the only reference to it?

Will fix in the next spin.

> 
> > +			new_filter->range_min = src_filter->range_min;
> > +			new_filter->range_max = src_filter->range_max;
> > +			break;
> >  		default:
> >  			break;
> >  		}
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260914144448.93732-1-sj@kernel.org?part=3
> 


Thanks,
SJ

  reply	other threads:[~2026-09-14 15:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 14:44 [RFC PATCH v2 0/8] mm/damon: introduce hugepage_size probe filter SJ Park
2026-09-14 14:44 ` [RFC PATCH v2 1/8] mm/damon/api: introduce DAMON_FILTER_TYPE_HUGEPAGE_SIZE SJ Park
2026-09-14 14:51   ` sashiko-bot
2026-09-14 14:44 ` [RFC PATCH v2 2/8] mm/damon/core: commit hugepage_size type damon filter SJ Park
2026-09-14 14:52   ` sashiko-bot
2026-09-14 14:59     ` SJ Park
2026-09-14 14:44 ` [RFC PATCH v2 3/8] mm/damon/ops-common: support hugepage_size damon filter matching SJ Park
2026-09-14 14:59   ` sashiko-bot
2026-09-14 15:17     ` SJ Park [this message]
2026-09-14 14:44 ` [RFC PATCH v2 4/8] mm/damon/sysfs: add min,max files under probe filter directory SJ Park
2026-09-14 14:48   ` sashiko-bot
2026-09-14 14:44 ` [RFC PATCH v2 5/8] mm/damon/sysfs: support hugepage_size probe filter SJ Park
2026-09-14 14:54   ` sashiko-bot
2026-09-14 15:00     ` SJ Park
2026-09-14 14:44 ` [RFC PATCH v2 6/8] Docs/mm/damon/design: update for " SJ Park
2026-09-14 14:46   ` sashiko-bot
2026-09-14 14:44 ` [RFC PATCH v2 7/8] Docs/admin-guide/mm/damon/usage: update for hugepage_size SJ Park
2026-09-14 14:46   ` sashiko-bot
2026-09-14 14:44 ` [RFC PATCH v2 8/8] Docs/ABI/damon: update for hugepage_size probe filter SJ Park
2026-09-14 14:46   ` sashiko-bot

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=20260914151746.98049-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-bot@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox