Unverified Commit c5226b96 authored by Konstantin Komarov's avatar Konstantin Komarov
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: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202512230646.v5hrYXL0-lkp@intel.com/


Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent c1f221c1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1256,6 +1256,12 @@ int ntfs_read_run_nb_ra(struct ntfs_sb_info *sbi, const struct runs_tree *run,

		} while (len32);

		if (!run) {
			err = -EINVAL;
			goto out;
		}

		/* Get next fragment to read. */
		vcn_next = vcn + clen;
		if (!run_get_entry(run, ++idx, &vcn, &lcn, &clen) ||
		    vcn != vcn_next) {