]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/ntfs3: Make ni_ins_new_attr return error
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Wed, 13 Jul 2022 16:18:19 +0000 (19:18 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:30 +0000 (13:09 +0100)
[ Upstream commit 451e45a0e6df21e63acfd493feb5194f4697ce11 ]

Function ni_ins_new_attr now returns ERR_PTR(err),
so we check it now in other functions like ni_expand_mft_list

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Stable-dep-of: 4d78d1173a65 ("fs/ntfs3: out1 also needs to put mi")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ntfs3/frecord.c

index b5f3e7bc5d6daf242cccb2dc06565bb1f9a4e9ff..4db52dfde6328b6cc99ba85135e76e922d603b7d 100644 (file)
@@ -470,7 +470,7 @@ ni_ins_new_attr(struct ntfs_inode *ni, struct mft_inode *mi,
                                &ref, &le);
                if (err) {
                        /* No memory or no space. */
-                       return NULL;
+                       return ERR_PTR(err);
                }
                le_added = true;
 
@@ -1000,6 +1000,8 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
                                       name_off, svcn, ins_le);
                if (!attr)
                        continue;
+               if (IS_ERR(attr))
+                       return PTR_ERR(attr);
 
                if (ins_attr)
                        *ins_attr = attr;
@@ -1021,8 +1023,15 @@ insert_ext:
 
        attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize,
                               name_off, svcn, ins_le);
-       if (!attr)
+       if (!attr) {
+               err = -EINVAL;
                goto out2;
+       }
+
+       if (IS_ERR(attr)) {
+               err = PTR_ERR(attr);
+               goto out2;
+       }
 
        if (ins_attr)
                *ins_attr = attr;
@@ -1034,7 +1043,6 @@ insert_ext:
 out2:
        ni_remove_mi(ni, mi);
        mi_put(mi);
-       err = -EINVAL;
 
 out1:
        ntfs_mark_rec_free(sbi, rno, is_mft);
@@ -1090,6 +1098,11 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
        if (asize <= free) {
                attr = ni_ins_new_attr(ni, &ni->mi, NULL, type, name, name_len,
                                       asize, name_off, svcn, ins_le);
+               if (IS_ERR(attr)) {
+                       err = PTR_ERR(attr);
+                       goto out;
+               }
+
                if (attr) {
                        if (ins_attr)
                                *ins_attr = attr;
@@ -1187,6 +1200,11 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
                goto out;
        }
 
+       if (IS_ERR(attr)) {
+               err = PTR_ERR(attr);
+               goto out;
+       }
+
        if (ins_attr)
                *ins_attr = attr;
        if (ins_mi)
@@ -1302,6 +1320,11 @@ static int ni_expand_mft_list(struct ntfs_inode *ni)
                goto out;
        }
 
+       if (IS_ERR(attr)) {
+               err = PTR_ERR(attr);
+               goto out;
+       }
+
        attr->non_res = 1;
        attr->name_off = SIZEOF_NONRESIDENT_LE;
        attr->flags = 0;