fs/ntfs3: Make ni_ins_new_attr return error

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>
This commit is contained in:
Konstantin Komarov 2022-07-13 19:18:19 +03:00
parent 8039edba04
commit 451e45a0e6
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6

View File

@ -469,7 +469,7 @@ ni_ins_new_attr(struct ntfs_inode *ni, struct mft_inode *mi,
&ref, &le); &ref, &le);
if (err) { if (err) {
/* No memory or no space. */ /* No memory or no space. */
return NULL; return ERR_PTR(err);
} }
le_added = true; le_added = true;
@ -1011,6 +1011,8 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
name_off, svcn, ins_le); name_off, svcn, ins_le);
if (!attr) if (!attr)
continue; continue;
if (IS_ERR(attr))
return PTR_ERR(attr);
if (ins_attr) if (ins_attr)
*ins_attr = attr; *ins_attr = attr;
@ -1032,8 +1034,15 @@ insert_ext:
attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize, attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize,
name_off, svcn, ins_le); name_off, svcn, ins_le);
if (!attr) if (!attr) {
err = -EINVAL;
goto out2; goto out2;
}
if (IS_ERR(attr)) {
err = PTR_ERR(attr);
goto out2;
}
if (ins_attr) if (ins_attr)
*ins_attr = attr; *ins_attr = attr;
@ -1045,7 +1054,6 @@ insert_ext:
out2: out2:
ni_remove_mi(ni, mi); ni_remove_mi(ni, mi);
mi_put(mi); mi_put(mi);
err = -EINVAL;
out1: out1:
ntfs_mark_rec_free(sbi, rno, is_mft); ntfs_mark_rec_free(sbi, rno, is_mft);
@ -1101,6 +1109,11 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
if (asize <= free) { if (asize <= free) {
attr = ni_ins_new_attr(ni, &ni->mi, NULL, type, name, name_len, attr = ni_ins_new_attr(ni, &ni->mi, NULL, type, name, name_len,
asize, name_off, svcn, ins_le); asize, name_off, svcn, ins_le);
if (IS_ERR(attr)) {
err = PTR_ERR(attr);
goto out;
}
if (attr) { if (attr) {
if (ins_attr) if (ins_attr)
*ins_attr = attr; *ins_attr = attr;
@ -1198,6 +1211,11 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
goto out; goto out;
} }
if (IS_ERR(attr)) {
err = PTR_ERR(attr);
goto out;
}
if (ins_attr) if (ins_attr)
*ins_attr = attr; *ins_attr = attr;
if (ins_mi) if (ins_mi)
@ -1313,6 +1331,11 @@ static int ni_expand_mft_list(struct ntfs_inode *ni)
goto out; goto out;
} }
if (IS_ERR(attr)) {
err = PTR_ERR(attr);
goto out;
}
attr->non_res = 1; attr->non_res = 1;
attr->name_off = SIZEOF_NONRESIDENT_LE; attr->name_off = SIZEOF_NONRESIDENT_LE;
attr->flags = 0; attr->flags = 0;