[paragon-software-group-ntfs3:master 2/16] fs/ntfs3/lib/lzx_decompress.c:555 lzx_decompress_block() error: uninitialized symbol 'match_offset'.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://github.com/Paragon-Software-Group/linux-ntfs3.git master
head:   7529036a025ad8bbd664f3aad8bd726e664a6db7
commit: 7495ce846bbe4f38d7ea5e023e44ad864b6348ad [2/16] fs/ntfs3: Use swap() to improve code
config: x86_64-randconfig-161-20240824 (https://download.01.org/0day-ci/archive/20240824/202408242247.tSSqBPqy-lkp@xxxxxxxxx/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202408242247.tSSqBPqy-lkp@xxxxxxxxx/

smatch warnings:
fs/ntfs3/lib/lzx_decompress.c:555 lzx_decompress_block() error: uninitialized symbol 'match_offset'.

vim +/match_offset +555 fs/ntfs3/lib/lzx_decompress.c

522e010b58379f Konstantin Komarov 2021-08-13  471  static int lzx_decompress_block(const struct lzx_decompressor *d,
522e010b58379f Konstantin Komarov 2021-08-13  472  				struct input_bitstream *is,
522e010b58379f Konstantin Komarov 2021-08-13  473  				int block_type, u32 block_size,
522e010b58379f Konstantin Komarov 2021-08-13  474  				u8 * const out_begin, u8 *out_next,
522e010b58379f Konstantin Komarov 2021-08-13  475  				u32 recent_offsets[])
522e010b58379f Konstantin Komarov 2021-08-13  476  {
522e010b58379f Konstantin Komarov 2021-08-13  477  	u8 * const block_end = out_next + block_size;
522e010b58379f Konstantin Komarov 2021-08-13  478  	u32 ones_if_aligned = 0U - (block_type == LZX_BLOCKTYPE_ALIGNED);
522e010b58379f Konstantin Komarov 2021-08-13  479  
522e010b58379f Konstantin Komarov 2021-08-13  480  	do {
522e010b58379f Konstantin Komarov 2021-08-13  481  		u32 mainsym;
522e010b58379f Konstantin Komarov 2021-08-13  482  		u32 match_len;
522e010b58379f Konstantin Komarov 2021-08-13  483  		u32 match_offset;
522e010b58379f Konstantin Komarov 2021-08-13  484  		u32 offset_slot;
522e010b58379f Konstantin Komarov 2021-08-13  485  		u32 num_extra_bits;
522e010b58379f Konstantin Komarov 2021-08-13  486  
522e010b58379f Konstantin Komarov 2021-08-13  487  		mainsym = read_mainsym(d, is);
522e010b58379f Konstantin Komarov 2021-08-13  488  		if (mainsym < LZX_NUM_CHARS) {
522e010b58379f Konstantin Komarov 2021-08-13  489  			/* Literal  */
522e010b58379f Konstantin Komarov 2021-08-13  490  			*out_next++ = mainsym;
522e010b58379f Konstantin Komarov 2021-08-13  491  			continue;
522e010b58379f Konstantin Komarov 2021-08-13  492  		}
522e010b58379f Konstantin Komarov 2021-08-13  493  
522e010b58379f Konstantin Komarov 2021-08-13  494  		/* Match  */
522e010b58379f Konstantin Komarov 2021-08-13  495  
522e010b58379f Konstantin Komarov 2021-08-13  496  		/* Decode the length header and offset slot.  */
522e010b58379f Konstantin Komarov 2021-08-13  497  		mainsym -= LZX_NUM_CHARS;
522e010b58379f Konstantin Komarov 2021-08-13  498  		match_len = mainsym % LZX_NUM_LEN_HEADERS;
522e010b58379f Konstantin Komarov 2021-08-13  499  		offset_slot = mainsym / LZX_NUM_LEN_HEADERS;
522e010b58379f Konstantin Komarov 2021-08-13  500  
522e010b58379f Konstantin Komarov 2021-08-13  501  		/* If needed, read a length symbol to decode the full length. */
522e010b58379f Konstantin Komarov 2021-08-13  502  		if (match_len == LZX_NUM_PRIMARY_LENS)
522e010b58379f Konstantin Komarov 2021-08-13  503  			match_len += read_lensym(d, is);
522e010b58379f Konstantin Komarov 2021-08-13  504  		match_len += LZX_MIN_MATCH_LEN;
522e010b58379f Konstantin Komarov 2021-08-13  505  
522e010b58379f Konstantin Komarov 2021-08-13  506  		if (offset_slot < LZX_NUM_RECENT_OFFSETS) {
522e010b58379f Konstantin Komarov 2021-08-13  507  			/* Repeat offset  */
522e010b58379f Konstantin Komarov 2021-08-13  508  
522e010b58379f Konstantin Komarov 2021-08-13  509  			/* Note: This isn't a real LRU queue, since using the R2
522e010b58379f Konstantin Komarov 2021-08-13  510  			 * offset doesn't bump the R1 offset down to R2.  This
522e010b58379f Konstantin Komarov 2021-08-13  511  			 * quirk allows all 3 recent offsets to be handled by
522e010b58379f Konstantin Komarov 2021-08-13  512  			 * the same code.  (For R0, the swap is a no-op.)
522e010b58379f Konstantin Komarov 2021-08-13  513  			 */
7495ce846bbe4f Thorsten Blum      2024-07-31  514  			swap(recent_offsets[offset_slot], recent_offsets[0]);

match_offset not set on this path

522e010b58379f Konstantin Komarov 2021-08-13  515  		} else {
522e010b58379f Konstantin Komarov 2021-08-13  516  			/* Explicit offset  */
522e010b58379f Konstantin Komarov 2021-08-13  517  
522e010b58379f Konstantin Komarov 2021-08-13  518  			/* Look up the number of extra bits that need to be read
522e010b58379f Konstantin Komarov 2021-08-13  519  			 * to decode offsets with this offset slot.
522e010b58379f Konstantin Komarov 2021-08-13  520  			 */
522e010b58379f Konstantin Komarov 2021-08-13  521  			num_extra_bits = lzx_extra_offset_bits[offset_slot];
522e010b58379f Konstantin Komarov 2021-08-13  522  
522e010b58379f Konstantin Komarov 2021-08-13  523  			/* Start with the offset slot base value.  */
522e010b58379f Konstantin Komarov 2021-08-13  524  			match_offset = lzx_offset_slot_base[offset_slot];
522e010b58379f Konstantin Komarov 2021-08-13  525  
522e010b58379f Konstantin Komarov 2021-08-13  526  			/* In aligned offset blocks, the low-order 3 bits of
522e010b58379f Konstantin Komarov 2021-08-13  527  			 * each offset are encoded using the aligned offset
522e010b58379f Konstantin Komarov 2021-08-13  528  			 * code.  Otherwise, all the extra bits are literal.
522e010b58379f Konstantin Komarov 2021-08-13  529  			 */
522e010b58379f Konstantin Komarov 2021-08-13  530  
522e010b58379f Konstantin Komarov 2021-08-13  531  			if ((num_extra_bits & ones_if_aligned) >= LZX_NUM_ALIGNED_OFFSET_BITS) {
522e010b58379f Konstantin Komarov 2021-08-13  532  				match_offset +=
522e010b58379f Konstantin Komarov 2021-08-13  533  					bitstream_read_bits(is, num_extra_bits -
522e010b58379f Konstantin Komarov 2021-08-13  534  								LZX_NUM_ALIGNED_OFFSET_BITS)
522e010b58379f Konstantin Komarov 2021-08-13  535  							<< LZX_NUM_ALIGNED_OFFSET_BITS;
522e010b58379f Konstantin Komarov 2021-08-13  536  				match_offset += read_alignedsym(d, is);
522e010b58379f Konstantin Komarov 2021-08-13  537  			} else {
522e010b58379f Konstantin Komarov 2021-08-13  538  				match_offset += bitstream_read_bits(is, num_extra_bits);
522e010b58379f Konstantin Komarov 2021-08-13  539  			}
522e010b58379f Konstantin Komarov 2021-08-13  540  
522e010b58379f Konstantin Komarov 2021-08-13  541  			/* Adjust the offset.  */
522e010b58379f Konstantin Komarov 2021-08-13  542  			match_offset -= (LZX_NUM_RECENT_OFFSETS - 1);
522e010b58379f Konstantin Komarov 2021-08-13  543  
522e010b58379f Konstantin Komarov 2021-08-13  544  			/* Update the recent offsets.  */
522e010b58379f Konstantin Komarov 2021-08-13  545  			recent_offsets[2] = recent_offsets[1];
522e010b58379f Konstantin Komarov 2021-08-13  546  			recent_offsets[1] = recent_offsets[0];
522e010b58379f Konstantin Komarov 2021-08-13  547  			recent_offsets[0] = match_offset;
522e010b58379f Konstantin Komarov 2021-08-13  548  		}
522e010b58379f Konstantin Komarov 2021-08-13  549  
522e010b58379f Konstantin Komarov 2021-08-13  550  		/* Validate the match, then copy it to the current position.  */
522e010b58379f Konstantin Komarov 2021-08-13  551  
522e010b58379f Konstantin Komarov 2021-08-13  552  		if (match_len > (size_t)(block_end - out_next))
522e010b58379f Konstantin Komarov 2021-08-13  553  			return -1;
522e010b58379f Konstantin Komarov 2021-08-13  554  
522e010b58379f Konstantin Komarov 2021-08-13 @555  		if (match_offset > (size_t)(out_next - out_begin))
                                                                    ^^^^^^^^^^^^
Uninitialized.

522e010b58379f Konstantin Komarov 2021-08-13  556  			return -1;
522e010b58379f Konstantin Komarov 2021-08-13  557  
522e010b58379f Konstantin Komarov 2021-08-13  558  		out_next = lz_copy(out_next, match_len, match_offset,
522e010b58379f Konstantin Komarov 2021-08-13  559  				   block_end, LZX_MIN_MATCH_LEN);
522e010b58379f Konstantin Komarov 2021-08-13  560  
522e010b58379f Konstantin Komarov 2021-08-13  561  	} while (out_next != block_end);
522e010b58379f Konstantin Komarov 2021-08-13  562  
522e010b58379f Konstantin Komarov 2021-08-13  563  	return 0;
522e010b58379f Konstantin Komarov 2021-08-13  564  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki





[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux