]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfs: handle single writeback rolling buffer allocation failure
authorYichong Chen <chenyichong@uniontech.com>
Mon, 27 Jul 2026 13:07:13 +0000 (14:07 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 28 Jul 2026 13:42:31 +0000 (15:42 +0200)
netfs_write_folio_single() takes an extra folio reference before
appending the folio to the rolling buffer.

rolling_buffer_append() can fail if it cannot allocate another
folio_queue. Check the return value and drop the extra folio reference
before returning the error.

Fixes: 49866ce7ea8d ("netfs: Add support for caching single monolithic objects such as AFS dirs")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260727130716.1099906-3-dhowells@redhat.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/netfs/write_issue.c

index f2761c99795a6b6aa4ecacd6902c8d696f31aaed..14efe4cb9393e517e360d7b02395f2cfaf8a31b4 100644 (file)
@@ -720,6 +720,7 @@ static int netfs_write_folio_single(struct netfs_io_request *wreq,
        size_t iter_off = 0;
        size_t fsize = folio_size(folio), flen;
        loff_t fpos = folio_pos(folio);
+       ssize_t ret;
        bool to_eof = false;
        bool no_debug = false;
 
@@ -748,7 +749,11 @@ static int netfs_write_folio_single(struct netfs_io_request *wreq,
 
        /* Attach the folio to the rolling buffer. */
        folio_get(folio);
-       rolling_buffer_append(&wreq->buffer, folio, NETFS_ROLLBUF_PUT_MARK);
+       ret = rolling_buffer_append(&wreq->buffer, folio, NETFS_ROLLBUF_PUT_MARK);
+       if (ret < 0) {
+               folio_put(folio);
+               return ret;
+       }
 
        /* Move the submission point forward to allow for write-streaming data
         * not starting at the front of the page.  We don't do write-streaming