[PATCH] ntfs3: Restore NULL folio initialization in ntfs_writepages()

Nathan Chancellor posted 1 patch 1 month ago
fs/ntfs3/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ntfs3: Restore NULL folio initialization in ntfs_writepages()
Posted by Nathan Chancellor 1 month ago
Clang warns (or errors with CONFIG_WERROR=y):

  fs/ntfs3/inode.c:1021:6: error: variable 'folio' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
   1021 |         if (is_resident(ni)) {
        |             ^~~~~~~~~~~~~~~
  fs/ntfs3/inode.c:1024:48: note: uninitialized use occurs here
   1024 |                 while ((folio = writeback_iter(mapping, wbc, folio, &err)))
        |                                                              ^~~~~

folio should be initialized to NULL for the first iteration of
writeback_iter() to start the loop properly. Restore the NULL
initialization of folio that was lost in the recent iomap conversion to
clear up the warning.

Fixes: 099ef9ab9203 ("fs/ntfs3: implement iomap-based file operations")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202601010644.FIhOXy6Y-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 fs/ntfs3/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index b969ad7c3258..438d468f28ba 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -1019,7 +1019,7 @@ static int ntfs_writepages(struct address_space *mapping,
 		return -EIO;
 
 	if (is_resident(ni)) {
-		struct folio *folio;
+		struct folio *folio = NULL;
 
 		while ((folio = writeback_iter(mapping, wbc, folio, &err)))
 			err = ntfs_resident_writepage(folio, wbc);

---
base-commit: 099ef9ab9203dff327f2d61e44773f9acbc01f13
change-id: 20260105-ntfs3-restore-null-folio-init-e3d7a7d6dd01

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>
Re: [PATCH] ntfs3: Restore NULL folio initialization in ntfs_writepages()
Posted by Konstantin Komarov 3 weeks ago
On 1/5/26 20:17, Nathan Chancellor wrote:

> Clang warns (or errors with CONFIG_WERROR=y):
>
>    fs/ntfs3/inode.c:1021:6: error: variable 'folio' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
>     1021 |         if (is_resident(ni)) {
>          |             ^~~~~~~~~~~~~~~
>    fs/ntfs3/inode.c:1024:48: note: uninitialized use occurs here
>     1024 |                 while ((folio = writeback_iter(mapping, wbc, folio, &err)))
>          |                                                              ^~~~~
>
> folio should be initialized to NULL for the first iteration of
> writeback_iter() to start the loop properly. Restore the NULL
> initialization of folio that was lost in the recent iomap conversion to
> clear up the warning.
>
> Fixes: 099ef9ab9203 ("fs/ntfs3: implement iomap-based file operations")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202601010644.FIhOXy6Y-lkp@intel.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>   fs/ntfs3/inode.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index b969ad7c3258..438d468f28ba 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -1019,7 +1019,7 @@ static int ntfs_writepages(struct address_space *mapping,
>   		return -EIO;
>   
>   	if (is_resident(ni)) {
> -		struct folio *folio;
> +		struct folio *folio = NULL;
>   
>   		while ((folio = writeback_iter(mapping, wbc, folio, &err)))
>   			err = ntfs_resident_writepage(folio, wbc);
>
> ---
> base-commit: 099ef9ab9203dff327f2d61e44773f9acbc01f13
> change-id: 20260105-ntfs3-restore-null-folio-init-e3d7a7d6dd01
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>

Queued for the next merge window, thanks.

Regards,
Konstantin