Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ntfs: fix variable dereferenced before check warnings

Detected by Smatch.

lcnalloc.c:736 ntfs_cluster_alloc() error:
we previously assumed 'rl' could be null (see line 719)

inode.c:3275 ntfs_inode_close() warn:
variable dereferenced before check 'tmp_nis' (see line 3255)

attrib.c:4952 ntfs_attr_remove() warn:
variable dereferenced before check 'ni' (see line 4951)

dir.c:1035 ntfs_readdir() error:
we previously assumed 'private' could be null (see line 850)

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

authored by

Hyunchul Lee and committed by
Namjae Jeon
4e59f8a1 7cf4b3c7

+16 -13
+3 -7
fs/ntfs/attrib.c
··· 4941 4941 int ntfs_attr_remove(struct ntfs_inode *ni, const __le32 type, __le16 *name, 4942 4942 u32 name_len) 4943 4943 { 4944 - struct super_block *sb; 4945 4944 int err; 4946 4945 struct inode *attr_vi; 4947 4946 struct ntfs_inode *attr_ni; 4948 4947 4949 4948 ntfs_debug("Entering\n"); 4950 4949 4951 - sb = ni->vol->sb; 4952 - if (!ni) { 4953 - ntfs_error(sb, "NULL inode pointer\n"); 4950 + if (!ni) 4954 4951 return -EINVAL; 4955 - } 4956 4952 4957 4953 attr_vi = ntfs_attr_iget(VFS_I(ni), type, name, name_len); 4958 4954 if (IS_ERR(attr_vi)) { 4959 4955 err = PTR_ERR(attr_vi); 4960 - ntfs_error(sb, "Failed to open attribute 0x%02x of inode 0x%llx", 4956 + ntfs_error(ni->vol->sb, "Failed to open attribute 0x%02x of inode 0x%llx", 4961 4957 type, (unsigned long long)ni->mft_no); 4962 4958 return err; 4963 4959 } ··· 4961 4965 4962 4966 err = ntfs_attr_rm(attr_ni); 4963 4967 if (err) 4964 - ntfs_error(sb, "Failed to remove attribute 0x%02x of inode 0x%llx", 4968 + ntfs_error(ni->vol->sb, "Failed to remove attribute 0x%02x of inode 0x%llx", 4965 4969 type, (unsigned long long)ni->mft_no); 4966 4970 iput(attr_vi); 4967 4971 return err;
+4 -2
fs/ntfs/dir.c
··· 1032 1032 } 1033 1033 1034 1034 if (err) { 1035 - private->curr_pos = actor->pos; 1036 - private->end_in_iterate = true; 1035 + if (private) { 1036 + private->curr_pos = actor->pos; 1037 + private->end_in_iterate = true; 1038 + } 1037 1039 err = 0; 1038 1040 } 1039 1041 ntfs_index_ctx_put(ictx);
+4 -1
fs/ntfs/inode.c
··· 3250 3250 * base inode before destroying it. 3251 3251 */ 3252 3252 base_ni = ni->ext.base_ntfs_ino; 3253 + tmp_nis = base_ni->ext.extent_ntfs_inos; 3254 + if (!tmp_nis) 3255 + goto out; 3253 3256 for (i = 0; i < base_ni->nr_extents; ++i) { 3254 - tmp_nis = base_ni->ext.extent_ntfs_inos; 3255 3257 if (tmp_nis[i] != ni) 3256 3258 continue; 3257 3259 /* Found it. Disconnect. */ ··· 3281 3279 break; 3282 3280 } 3283 3281 3282 + out: 3284 3283 if (NInoDirty(ni)) 3285 3284 ntfs_error(ni->vol->sb, "Releasing dirty inode %llu!\n", 3286 3285 ni->mft_no);
+4 -2
fs/ntfs/lcnalloc.c
··· 732 732 folio_put(folio); 733 733 } 734 734 if (likely(!err)) { 735 + if (!rl) { 736 + err = -EIO; 737 + goto out_restore; 738 + } 735 739 if (is_dealloc == true) 736 740 ntfs_release_dirty_clusters(vol, rl->length); 737 741 ntfs_debug("Done."); 738 - if (rl == NULL) 739 - err = -EIO; 740 742 goto out_restore; 741 743 } 742 744 if (err != -ENOSPC)
+1 -1
fs/ntfs/runlist.c
··· 1661 1661 { 1662 1662 struct runlist_element *i_rl, *new_rl, *src_rl_origin = src_rl; 1663 1663 struct runlist_element dst_rl_split; 1664 - s64 start_vcn = src_rl[0].vcn; 1664 + s64 start_vcn; 1665 1665 int new_1st_cnt, new_2nd_cnt, new_3rd_cnt, new_cnt; 1666 1666 1667 1667 if (!dst_rl || !src_rl || !new_rl_cnt)