Re: [PATCH v2] fs: ext4: fix uninitialized symbols
From: Theodore Ts'o
Date: Sun Oct 12 2025 - 15:08:07 EST
On Sat, Oct 11, 2025 at 12:08:29PM +0530, Ranganath V N wrote:
> Fix the issue detected by the smatch tool.
>
> fs/ext4/inode.c:3583 ext4_map_blocks_atomic_write_slow() error: uninitialized symbol 'next_pblk'.
This one is valid, and I agree with your proposed changed. (Although
the worst that will happen is that in case of an ENOSPC error comined
with a corrpted file system the warning message may print an
uninitialized value. So not a big eal, but we might as well fix it.)
> fs/ext4/namei.c:1776 ext4_lookup() error: uninitialized symbol 'de'.
This is a false positive for smatch. There isn't actualy a prolem
here, because all of these funtions are calling ext4_find_entry() or
ext4_lookup_entry(), and the callers will not try to dereference the
pointer passed into *res_dir ('de') if the function has either
returned NULL or an ERR_PTR(), and that's in fact correct.
I don't especially mind the fix (but I do wish smatch could be
smarter). Out of curiosity, if we move the *res_dir = NULL from
__ext4_find_entry() and move it so it's unconditionally set in
ext4_find_entry() and ext4_lookup_entry(), is that sufficient to make
smatch stop complaining?
- Ted