Skip to contentSkip to conversation

fs/ntfs3: add delayed-allocation (delalloc) support

bug report Dan Carpenter 2 participants 2 messages Apr 10 – Apr 15 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

Hello Konstantin Komarov,

Commit 10d7c95af043 ("fs/ntfs3: add delayed-allocation (delalloc) support") from Feb 16, 2026 (linux-next), leads to the following Smatch static checker warning:

	fs/ntfs3/frecord.c:3303 ni_allocate_da_blocks_locked()
	error: uninitialized symbol 'err'.

fs/ntfs3/frecord.c

    3268 int ni_allocate_da_blocks_locked(struct ntfs_inode *ni)
    3269 {
    3270         int err;
    3271 
    3272         if (!ni->file.run_da.count)
    3273                 return 0;
    3274 
    3275         if (is_sparsed(ni)) {
    3276                 CLST vcn, lcn, clen, alen;
    3277                 bool new;
    3278 
    3279                 /*
    3280                  * Sparse file allocates clusters in 'attr_data_get_block_locked'
    3281                  */
    3282                 while (run_get_entry(&ni->file.run_da, 0, &vcn, &lcn, &clen)) {

Do we always enter this loop for at least on iteration? Otherwise ...

    3283                         /* TODO: zero=true? */
    3284                         err = attr_data_get_block_locked(ni, vcn, clen, &lcn,
    3285                                                          &alen, &new, true,
    3286                                                          NULL, true);
    3287                         if (err)
    3288                                 break;
    3289                         if (!new) {
    3290                                 err = -EINVAL;
    3291                                 break;
    3292                         }
    3293                 }
    3294         } else {
    3295                 /*
    3296                  * Normal file allocates clusters in 'attr_set_size'
    3297                  */
    3298                 err = attr_set_size_ex(ni, ATTR_DATA, NULL, 0, &ni->file.run,
    3299                                        ni->vfs_inode.i_size, &ni->i_valid,
    3300                                        false, NULL, true);
    3301         }
    3302 

--> 3303 return err;

err would be uninitialized

    3304 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

#1 lore raw
Quoted 50 lines · Dan Carpenter

Hello Konstantin Komarov,

Commit 10d7c95af043 ("fs/ntfs3: add delayed-allocation (delalloc) support") from Feb 16, 2026 (linux-next), leads to the following Smatch static checker warning:

	fs/ntfs3/frecord.c:3303 ni_allocate_da_blocks_locked()
	error: uninitialized symbol 'err'.

fs/ntfs3/frecord.c

     3268 int ni_allocate_da_blocks_locked(struct ntfs_inode *ni)
     3269 {
     3270         int err;
     3271
     3272         if (!ni->file.run_da.count)
     3273                 return 0;
     3274
     3275         if (is_sparsed(ni)) {
     3276                 CLST vcn, lcn, clen, alen;
     3277                 bool new;
     3278
     3279                 /*
     3280                  * Sparse file allocates clusters in 'attr_data_get_block_locked'
     3281                  */
     3282                 while (run_get_entry(&ni->file.run_da, 0, &vcn, &lcn, &clen)) {

Do we always enter this loop for at least on iteration? Otherwise ...

     3283                         /* TODO: zero=true? */
     3284                         err = attr_data_get_block_locked(ni, vcn, clen, &lcn,
     3285                                                          &alen, &new, true,
     3286                                                          NULL, true);
     3287                         if (err)
     3288                                 break;
     3289                         if (!new) {
     3290                                 err = -EINVAL;
     3291                                 break;
     3292                         }
     3293                 }
     3294         } else {
     3295                 /*
     3296                  * Normal file allocates clusters in 'attr_set_size'
     3297                  */
     3298                 err = attr_set_size_ex(ni, ATTR_DATA, NULL, 0, &ni->file.run,
     3299                                        ni->vfs_inode.i_size, &ni->i_valid,
     3300                                        false, NULL, true);
     3301         }
     3302

--> 3303 return err;

Quoted 8 lines

err would be uninitialized

     3304 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

Hello,

Thank you. The warning was fixed by the patch:
https://lore.kernel.org/ntfs3/[email protected]/

Regards,
Konstantin