Skip to content

Commit 14f527d

Browse files
fs/ntfs3: Correct checking while generating attr_list
Correct slightly previous commit: Enhance sanity check while generating attr_list Signed-off-by: Konstantin Komarov <[email protected]>
1 parent ea303f7 commit 14f527d

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

fs/ntfs3/frecord.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,8 @@ int ni_create_attr_list(struct ntfs_inode *ni)
813813
* Looks like one record_size is always enough.
814814
*/
815815
le = kmalloc(al_aligned(rs), GFP_NOFS);
816-
if (!le) {
817-
err = -ENOMEM;
818-
goto out;
819-
}
816+
if (!le)
817+
return -ENOMEM;
820818

821819
mi_get_ref(&ni->mi, &le->ref);
822820
ni->attr_list.le = le;
@@ -865,14 +863,14 @@ int ni_create_attr_list(struct ntfs_inode *ni)
865863

866864
if (to_free > free_b) {
867865
err = -EINVAL;
868-
goto out1;
866+
goto out;
869867
}
870868
}
871869

872870
/* Allocate child MFT. */
873871
err = ntfs_look_free_mft(sbi, &rno, is_mft, ni, &mi);
874872
if (err)
875-
goto out1;
873+
goto out;
876874

877875
err = -EINVAL;
878876
/* Call mi_remove_attr() in reverse order to keep pointers 'arr_move' valid. */
@@ -884,7 +882,7 @@ int ni_create_attr_list(struct ntfs_inode *ni)
884882
attr = mi_insert_attr(mi, b->type, Add2Ptr(b, name_off),
885883
b->name_len, asize, name_off);
886884
if (!attr)
887-
goto out1;
885+
goto out;
888886

889887
mi_get_ref(mi, &le_b[nb]->ref);
890888
le_b[nb]->id = attr->id;
@@ -895,19 +893,19 @@ int ni_create_attr_list(struct ntfs_inode *ni)
895893

896894
/* Remove from primary record. */
897895
if (!mi_remove_attr(NULL, &ni->mi, b))
898-
goto out1;
896+
goto out;
899897

900898
if (to_free <= asize)
901899
break;
902900
to_free -= asize;
903901
if (!nb)
904-
goto out1;
902+
goto out;
905903
}
906904

907905
attr = mi_insert_attr(&ni->mi, ATTR_LIST, NULL, 0,
908906
lsize + SIZEOF_RESIDENT, SIZEOF_RESIDENT);
909907
if (!attr)
910-
goto out1;
908+
goto out;
911909

912910
attr->non_res = 0;
913911
attr->flags = 0;
@@ -921,16 +919,13 @@ int ni_create_attr_list(struct ntfs_inode *ni)
921919
ni->attr_list.dirty = false;
922920

923921
mark_inode_dirty(&ni->vfs_inode);
924-
goto out;
922+
return 0;
925923

926-
out1:
924+
out:
927925
kfree(ni->attr_list.le);
928926
ni->attr_list.le = NULL;
929927
ni->attr_list.size = 0;
930928
return err;
931-
932-
out:
933-
return 0;
934929
}
935930

936931
/*

0 commit comments

Comments
 (0)