mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ntfs3: avoid -Wmaybe-uninitialized warning
@ 2026-04-21 20:26 Arnd Bergmann
  2026-05-22 13:41 ` Konstantin Komarov
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2026-04-21 20:26 UTC (permalink / raw)
  To: Konstantin Komarov
  Cc: Arnd Bergmann, Moon Hee Lee, Seunghun Han, Kees Cook,
	Deepanshu Kartikey, Andrey Vatoropin, Lalit Shankar Chowdhury,
	Lizhi Xu, Adarsh Das, Jaehun Gou, ntfs3, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

This warning shows up with gcc-10 now:

In file included from fs/ntfs3/index.c:15:
fs/ntfs3/index.c: In function 'indx_add_allocate':
fs/ntfs3/ntfs_fs.h:463:9: error: 'bmp_size' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  463 |  return attr_set_size_ex(ni, type, name, name_len, run, new_size,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  464 |     new_valid, keep_prealloc, NULL, false);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/ntfs3/index.c:1498:6: note: 'bmp_size' was declared here
 1498 |  u64 bmp_size, bmp_size_v;
      |      ^~~~~~~~

The warning does look correct, as the 'out2' label can be reached
without initializing bmp_size and bmp_size_v. Initialize these at
the same place as bmp.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Note that this is one is separate from the one I reported with KCSAN
---
 fs/ntfs3/index.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 5344b29b0577..2b8b5779ff8a 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -1506,6 +1506,7 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
 
 	if (bit != MINUS_ONE_T) {
 		bmp = NULL;
+		bmp_size = bmp_size_v = 0;
 	} else {
 		if (bmp->non_res) {
 			bmp_size = le64_to_cpu(bmp->nres.data_size);
-- 
2.39.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ntfs3: avoid -Wmaybe-uninitialized warning
  2026-04-21 20:26 [PATCH] ntfs3: avoid -Wmaybe-uninitialized warning Arnd Bergmann
@ 2026-05-22 13:41 ` Konstantin Komarov
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Komarov @ 2026-05-22 13:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Moon Hee Lee, Seunghun Han, Kees Cook,
	Deepanshu Kartikey, Andrey Vatoropin, Lalit Shankar Chowdhury,
	Lizhi Xu, Adarsh Das, Jaehun Gou, ntfs3, linux-kernel

On 4/21/26 22:26, Arnd Bergmann wrote:

> From: Arnd Bergmann <arnd@arndb.de>
>
> This warning shows up with gcc-10 now:
>
> In file included from fs/ntfs3/index.c:15:
> fs/ntfs3/index.c: In function 'indx_add_allocate':
> fs/ntfs3/ntfs_fs.h:463:9: error: 'bmp_size' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    463 |  return attr_set_size_ex(ni, type, name, name_len, run, new_size,
>        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    464 |     new_valid, keep_prealloc, NULL, false);
>        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> fs/ntfs3/index.c:1498:6: note: 'bmp_size' was declared here
>   1498 |  u64 bmp_size, bmp_size_v;
>        |      ^~~~~~~~
>
> The warning does look correct, as the 'out2' label can be reached
> without initializing bmp_size and bmp_size_v. Initialize these at
> the same place as bmp.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Note that this is one is separate from the one I reported with KCSAN
> ---
>   fs/ntfs3/index.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
> index 5344b29b0577..2b8b5779ff8a 100644
> --- a/fs/ntfs3/index.c
> +++ b/fs/ntfs3/index.c
> @@ -1506,6 +1506,7 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
>   
>   	if (bit != MINUS_ONE_T) {
>   		bmp = NULL;
> +		bmp_size = bmp_size_v = 0;
>   	} else {
>   		if (bmp->non_res) {
>   			bmp_size = le64_to_cpu(bmp->nres.data_size);

Hello,

Sorry for the delay.
Your patch is applied, thank you.

Regards,
Konstantin


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-22 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-21 20:26 [PATCH] ntfs3: avoid -Wmaybe-uninitialized warning Arnd Bergmann
2026-05-22 13:41 ` Konstantin Komarov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®