From: Henrique Carvalho <henrique.carvalho@suse.com>
To: Enzo Matsumiya <ematsumiya@suse.de>
Cc: Steve French <smfrench@gmail.com>,
pc@manguebit.com, ronniesahlberg@gmail.com,
sprasad@microsoft.com, paul@darkrain42.org,
bharathsm@microsoft.com, linux-cifs@vger.kernel.org,
Meetakshi Setiya <msetiya@microsoft.com>
Subject: Re: [PATCH] smb: cached_dir.c: fix race in cfid release
Date: Fri, 2 May 2025 17:20:31 -0300 [thread overview]
Message-ID: <aBUpD0LzzzPUbRjz@precision> (raw)
In-Reply-To: <fh2ose2otti5opro6jmpoo6dr4uhc2nfdrlgo3e2ikim4y4gqq@7zxtxyyhphah>
On Fri, May 02, 2025 at 04:58:00PM -0300, Enzo Matsumiya wrote:
> On 05/02, Steve French wrote:
> > I fixed a minor checkpatch warning but also noticed this compile
> > warning - is there a missing lock call?
> >
> > cached_dir.c:429:20: warning: context imbalance in 'cfid_release' -
> > unexpected unlock
>
> The lock is taken (inside kref_put_lock) if count == 0 (i.e. when the
> release function is called) and must be released from within the
> release function (which is done here).
>
> However, sparse can't recognize this and also there doesn't seem to
> exist an annotation to indicate so.
>
> @Henrique do you think you could rework the patch to something like:
>
> cfid_release() {
> list_del();
> on_list = false;
> num_entries--;
> }
>
> cfid_put() {
> lock();
> if (kref_put(..., cfid_release)) {
> unlock();
> dput();
> SMB2_close();
> free_cached_dir();
> return;
> }
> unlock();
> }
>
@Enzo, good idea. I will rework the patch.
Henrique
next prev parent reply other threads:[~2025-05-02 20:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 18:01 [PATCH] smb: cached_dir.c: fix race in cfid release Henrique Carvalho
2025-05-02 19:07 ` Steve French
2025-05-02 19:58 ` Enzo Matsumiya
2025-05-02 20:20 ` Henrique Carvalho [this message]
2025-05-02 20:59 ` Henrique Carvalho
2025-05-02 21:54 ` Steve French
2025-05-02 22:41 ` Henrique Carvalho
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=aBUpD0LzzzPUbRjz@precision \
--to=henrique.carvalho@suse.com \
--cc=bharathsm@microsoft.com \
--cc=ematsumiya@suse.de \
--cc=linux-cifs@vger.kernel.org \
--cc=msetiya@microsoft.com \
--cc=paul@darkrain42.org \
--cc=pc@manguebit.com \
--cc=ronniesahlberg@gmail.com \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.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