From c9d442c4069e6d290e2d62f0ee10a4886e23061b Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 15 Apr 2026 12:06:42 -0700 Subject: [PATCH] Initialize ref_blkno output at the start of block_dirty_ref() scoutfs_block_dirty_ref() only sets *ref_blkno on the path that allocates a new cow block. The early return paths leave it untouched, so a caller that reads it back gets whatever value was on the stack. This is harmless with the current callers. dirty_alloc_blocks() bails out before calling here when the blocks are already dirty, so the early return on an already-dirty block is never reached, and the error paths return a negative value that callers check before using ref_blkno. Signed-off-by: Auke Kok --- kmod/src/block.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kmod/src/block.c b/kmod/src/block.c index 7d28758e..18df2df3 100644 --- a/kmod/src/block.c +++ b/kmod/src/block.c @@ -836,6 +836,9 @@ int scoutfs_block_dirty_ref(struct super_block *sb, struct scoutfs_alloc *alloc, int ret; int err; + if (ref_blkno) + *ref_blkno = 0; + /* read existing referenced block, if any */ blkno = le64_to_cpu(ref->blkno); if (blkno) {