Skip to content

Commit c5226b9

Browse files
fs/ntfs3: avoid calling run_get_entry() when run == NULL in ntfs_read_run_nb_ra()
When ntfs_read_run_nb_ra() is invoked with run == NULL the code later assumes run is valid and may call run_get_entry(NULL, ...), and also uses clen/idx without initializing them. Smatch reported uninitialized variable warnings and this can lead to undefined behaviour. This patch fixes it. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202512230646.v5hrYXL0-lkp@intel.com/ Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent c1f221c commit c5226b9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

fs/ntfs3/fsntfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,12 @@ int ntfs_read_run_nb_ra(struct ntfs_sb_info *sbi, const struct runs_tree *run,
12561256

12571257
} while (len32);
12581258

1259+
if (!run) {
1260+
err = -EINVAL;
1261+
goto out;
1262+
}
1263+
1264+
/* Get next fragment to read. */
12591265
vcn_next = vcn + clen;
12601266
if (!run_get_entry(run, ++idx, &vcn, &lcn, &clen) ||
12611267
vcn != vcn_next) {

0 commit comments

Comments
 (0)