[bug report] fs/ntfs3: inconsistent NULL checking in do_action()

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

 



Hello Konstantin Komarov,

This is a semi-automatic email about new static checker warnings.

The patch b46acd6a6a62: "fs/ntfs3: Add NTFS journal" from Aug 13, 
2021, leads to the following Smatch complaint:

    fs/ntfs3/fslog.c:3141 do_action()
    warn: variable dereferenced before check 'mi' (see line 3102)

fs/ntfs3/fslog.c
  3101			}
  3102			rec = mi->mrec;
                              ^^^^^^^^
Dereferenced

  3103	
  3104			if (op == DeallocateFileRecordSegment)
  3105				goto skip_load_parent;
  3106	
  3107			if (InitializeFileRecordSegment != op) {
  3108				if (rec->rhdr.sign == NTFS_BAAD_SIGNATURE)
  3109					goto dirty_vol;
  3110				if (!check_lsn(&rec->rhdr, rlsn))
  3111					goto out;
  3112				if (!check_file_record(rec, NULL, sbi))
  3113					goto dirty_vol;
  3114				attr = Add2Ptr(rec, roff);
  3115			}
  3116	
  3117			if (is_rec_base(rec) || InitializeFileRecordSegment == op) {
  3118				rno_base = rno;
  3119				goto skip_load_parent;
  3120			}
  3121	
  3122			rno_base = ino_get(&rec->parent_ref);
  3123			inode_parent = ntfs_iget5(sbi->sb, &rec->parent_ref, NULL);
  3124			if (IS_ERR(inode_parent))
  3125				goto skip_load_parent;
  3126	
  3127			if (is_bad_inode(inode_parent)) {
  3128				iput(inode_parent);
  3129				goto skip_load_parent;
  3130			}
  3131	
  3132			if (ni_load_mi_ex(ntfs_i(inode_parent), rno, &mi2_child)) {
  3133				iput(inode_parent);
  3134			} else {
  3135				if (mi2_child->mrec != mi->mrec)
                                                       ^^^^^^^^
Dereferenced.

  3136					memcpy(mi2_child->mrec, mi->mrec,
  3137					       sbi->record_size);
  3138	
  3139				if (inode)
  3140					iput(inode);
  3141				else if (mi)
                                         ^^
Checked too late.

  3142					mi_put(mi);
  3143	

regards,
dan carpenter




[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