From: Harry Yoo <harry.yoo@oracle.com>
To: kernel test robot <lkp@intel.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>,
oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Gregory Price <gourry@gourry.net>,
Huang Ying <ying.huang@linux.alibaba.com>,
Honggyu Kim <honggyu.kim@sk.com>
Subject: Re: mm/mempolicy.c:3719:1-6: ERROR: invalid free of structure field
Date: Mon, 2 Jun 2025 15:01:08 +0900 [thread overview]
Message-ID: <aD0-JNr0Z83OpXg4@harry> (raw)
In-Reply-To: <202506011545.Fduxqxqj-lkp@intel.com>
On Sun, Jun 01, 2025 at 01:34:46PM +0800, kernel test robot wrote:
> cocci warnings: (new ones prefixed by >>)
> >> mm/mempolicy.c:3719:1-6: ERROR: invalid free of structure field
>
> vim +3719 mm/mempolicy.c
>
> 3700
> 3701 static void wi_state_free(void)
> 3702 {
> 3703 struct weighted_interleave_state *old_wi_state;
> 3704
> 3705 mutex_lock(&wi_state_lock);
> 3706
> 3707 old_wi_state = rcu_dereference_protected(wi_state,
> 3708 lockdep_is_held(&wi_state_lock));
> 3709 if (!old_wi_state) {
> 3710 mutex_unlock(&wi_state_lock);
> 3711 goto out;
> 3712 }
> 3713
> 3714 rcu_assign_pointer(wi_state, NULL);
> 3715 mutex_unlock(&wi_state_lock);
> 3716 synchronize_rcu();
> 3717 kfree(old_wi_state);
> 3718 out:
> > 3719 kfree(&wi_group->wi_kobj);
Hmm maybe Joshua meant kfree(wi_group)?
Anyway, practically it's the same as kfree(wi_group) and something strange
is happening there.
in add_weighted_interleave_group() (the only caller of wi_cleanup()),
kobject_del() and kobject_put() are called after wi_cleanup() freed
wi_group in the error path.
> 3720 }
> 3721
>
> --
> 0-DAY CI Kernel Test Service
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2025-06-02 6:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-01 5:34 kernel test robot
2025-06-02 6:01 ` Harry Yoo [this message]
2025-06-02 14:52 ` Joshua Hahn
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=aD0-JNr0Z83OpXg4@harry \
--to=harry.yoo@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=gourry@gourry.net \
--cc=honggyu.kim@sk.com \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=ying.huang@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox