]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfs: Fix leak of request in netfs_write_begin() error handling
authorDavid Howells <dhowells@redhat.com>
Tue, 12 May 2026 12:33:55 +0000 (13:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 12 May 2026 12:42:32 +0000 (14:42 +0200)
Fix netfs_write_begin() to not leak our ref on the request in the event
that we get an error from netfs_wait_for_read().

Fixes: 4090b31422a6 ("netfs: Add a function to consolidate beginning a read")
Closes: https://sashiko.dev/#/patchset/20260414082004.3756080-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260512123404.719402-19-dhowells@redhat.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: Matthew Wilcox <willy@infradead.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/buffered_read.c

index e7ad511e494cc7085e7d3b6828d5aff0d97167d6..004d426c02b41708a309ee03bb97104a3e51fa39 100644 (file)
@@ -687,9 +687,9 @@ retry:
 
        netfs_read_to_pagecache(rreq, NULL);
        ret = netfs_wait_for_read(rreq);
+       netfs_put_request(rreq, netfs_rreq_trace_put_return);
        if (ret < 0)
                goto error;
-       netfs_put_request(rreq, netfs_rreq_trace_put_return);
 
 have_folio:
        ret = folio_wait_private_2_killable(folio);