From: David Howells <dhowells@redhat.com>
To: Max Kellermann <max.kellermann@ionos.com>
Cc: dhowells@redhat.com, Paulo Alcantara <pc@manguebit.org>,
Christian Brauner <brauner@kernel.org>,
netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-stable@vger.kernel.org
Subject: Re: [PATCH] fs/netfs: fix reference leak
Date: Wed, 24 Sep 2025 20:10:20 +0100 [thread overview]
Message-ID: <845700.1758741020@warthog.procyon.org.uk> (raw)
In-Reply-To: <CAKPOu+9Ym+dRHQiMvjvdisnb5jwca4_2ECbzOMLYso=xNvxeQQ@mail.gmail.com>
Max Kellermann <max.kellermann@ionos.com> wrote:
> > if (!__refcount_sub_and_test(2, &rreq->ref, &r))
> > WARN_ON_ONCE(1);
> > ...
> > trace_netfs_rreq_ref(rreq->debug_id, r, netfs_rreq_trace_put_failed);
>
> You changed the refcount_read() check to an atomic decrement, but at
> this point, nobody cares for the reference counter anymore (and my
> check was just for bug-catching purposes).
> Why bother doing the decrement?
Well, an atomic subtract, but yes. I would at least log the revised refcount
- which actually I've done wrong. The trace line needs r-2, not r, as the
__refcount_*() routines return the original value, not the modified value (the
opposite of the atomic_*() routines).
I think the refcount should probably be 0 when we get to
netfs_free_request_rcu() for consistency (and I've occasionally had a check
there), but I can live with a just a warning and the trace line printing the
current refcount.
David
prev parent reply other threads:[~2025-09-24 19:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 22:24 [PATCH] fs/netfs: fix reference leak Max Kellermann
2025-09-11 22:27 ` Fwd: " Max Kellermann
2025-09-12 5:36 ` Greg KH
2025-09-24 15:24 ` David Howells
2025-09-24 15:39 ` David Howells
2025-09-24 18:52 ` Max Kellermann
2025-09-24 19:10 ` David Howells [this message]
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=845700.1758741020@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stable@vger.kernel.org \
--cc=max.kellermann@ionos.com \
--cc=netfs@lists.linux.dev \
--cc=pc@manguebit.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 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.