Skip to content

Commit

Permalink
fs/ntfs3: Make ni_ins_new_attr return error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Konstantin Komarov committed Aug 3, 2022
1 parent 8039edb commit 451e45a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions fs/ntfs3/frecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,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;

Expand Down Expand Up @@ -1011,6 +1011,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;
Expand All @@ -1032,8 +1034,15 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,

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;
Expand All @@ -1045,7 +1054,6 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
out2:
ni_remove_mi(ni, mi);
mi_put(mi);
err = -EINVAL;

out1:
ntfs_mark_rec_free(sbi, rno, is_mft);
Expand Down Expand Up @@ -1101,6 +1109,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;
Expand Down Expand Up @@ -1198,6 +1211,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)
Expand Down Expand Up @@ -1313,6 +1331,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;
Expand Down

0 comments on commit 451e45a

Please sign in to comment.