* [bug report] fs/ntfs3: Rework file operations
@ 2021-09-02 10:25 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-09-02 10:25 UTC (permalink / raw)
To: almaz.alexandrovich; +Cc: ntfs3
Hello Konstantin Komarov,
This is a semi-automatic email about new static checker warnings.
The patch 78ab59fee07f: "fs/ntfs3: Rework file operations" from Aug
31, 2021, leads to the following Smatch complaint:
fs/ntfs3/frecord.c:2887 ni_remove_name_undo()
error: we previously assumed 'de2' could be null (see line 2876)
fs/ntfs3/frecord.c
2871 bool ni_remove_name_undo(struct ntfs_inode *dir_ni, struct ntfs_inode *ni,
2872 struct NTFS_DE *de, struct NTFS_DE *de2, int undo_step)
2873 {
2874 struct ntfs_sb_info *sbi = ni->mi.sbi;
2875 struct ATTRIB *attr;
2876 u16 de_key_size = de2 ? le16_to_cpu(de2->key_size) : 0;
^^^
This assumes "de2" can be NULL.
2877
2878 switch (undo_step) {
2879 case 4:
2880 if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0,
2881 &attr, NULL, NULL)) {
2882 return false;
2883 }
2884 memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), de2 + 1, de_key_size);
2885
2886 mi_get_ref(&ni->mi, &de2->ref);
^^^^^^^^^
Unchecked dereference.
2887 de2->size = cpu_to_le16(ALIGN(de_key_size, 8) +
2888 sizeof(struct NTFS_DE));
2889 de2->flags = 0;
2890 de2->res = 0;
2891
2892 if (indx_insert_entry(&dir_ni->dir, dir_ni, de2, sbi, NULL,
2893 1)) {
2894 return false;
2895 }
2896 fallthrough;
2897
2898 case 2:
2899 de_key_size = le16_to_cpu(de->key_size);
No need for this assignment.
2900
2901 if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0,
2902 &attr, NULL, NULL)) {
2903 return false;
2904 }
2905
2906 memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), de + 1, de_key_size);
2907 mi_get_ref(&ni->mi, &de->ref);
2908
2909 if (indx_insert_entry(&dir_ni->dir, dir_ni, de, sbi, NULL, 1)) {
2910 return false;
2911 }
2912 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-02 10:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 10:25 [bug report] fs/ntfs3: Rework file operations Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).