* [PATCH v2 1/9] netfs: Fix uninitialized return value in netfs_unbuffered_write()
[not found] <20260825132045.1000787-1-dhowells@redhat.com>
@ 2026-08-25 13:20 ` David Howells
0 siblings, 0 replies; only message in thread
From: David Howells @ 2026-08-25 13:20 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Paulo Alcantara, netfs, linux-afs, linux-cifs,
ceph-devel, linux-fsdevel, linux-kernel, Karl Mehltretter, stable
From: Karl Mehltretter <kmehltretter@gmail.com>
If preparation of the first subrequest fails,
netfs_unbuffered_write() exits its loop before ret is initialized. The
empty-iterator check can do the same.
For synchronous writes, netfs_unbuffered_write_iter_locked() may then
return an unrelated error instead of wreq->error. This is reachable
through CIFS if cifs_prepare_write() fails to reopen the file or obtain
credits.
Initialize ret to 0 so the caller returns wreq->error if no data was
written, or the number of bytes already written otherwise.
Found with Clang's -Wconditional-uninitialized.
Fixes: a0b4c7a49137e ("netfs: Fix unbuffered/DIO writes to dispatch subrequests in strict sequence")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-fable-5
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/netfs/direct_write.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index c16fbad286a1..b04019097ab8 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -95,7 +95,7 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)
{
struct netfs_io_subrequest *subreq = NULL;
struct netfs_io_stream *stream = &wreq->io_streams[0];
- int ret;
+ int ret = 0;
_enter("%llx", wreq->len);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-25 13:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260825132045.1000787-1-dhowells@redhat.com>
2026-08-25 13:20 ` [PATCH v2 1/9] netfs: Fix uninitialized return value in netfs_unbuffered_write() David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox