Skip to content
/ linux Public

Commit 2f5c626

Browse files
aalexandrovichSasha Levin
authored andcommitted
fs/ntfs3: avoid calling run_get_entry() when run == NULL in ntfs_read_run_nb_ra()
[ Upstream commit c5226b9 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ad0d779 commit 2f5c626

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/ntfs3/fsntfs.c

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

12731273
} while (len32);
12741274

1275+
if (!run) {
1276+
err = -EINVAL;
1277+
goto out;
1278+
}
1279+
1280+
/* Get next fragment to read. */
12751281
vcn_next = vcn + clen;
12761282
if (!run_get_entry(run, ++idx, &vcn, &lcn, &clen) ||
12771283
vcn != vcn_next) {

0 commit comments

Comments
 (0)