Skip to content

Commit aaab47f

Browse files
fs/ntfs3: Add NULL ptr dereference checking at the end of attr_allocate_frame()
It is preferable to exit through the out: label because internal debugging functions are located there. Signed-off-by: Konstantin Komarov <[email protected]>
1 parent d6ca2d2 commit aaab47f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

fs/ntfs3/attrib.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,8 +1743,10 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
17431743
le_b = NULL;
17441744
attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL,
17451745
0, NULL, &mi_b);
1746-
if (!attr_b)
1747-
return -ENOENT;
1746+
if (!attr_b) {
1747+
err = -ENOENT;
1748+
goto out;
1749+
}
17481750

17491751
attr = attr_b;
17501752
le = le_b;
@@ -1825,13 +1827,15 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
18251827
ok:
18261828
run_truncate_around(run, vcn);
18271829
out:
1828-
if (new_valid > data_size)
1829-
new_valid = data_size;
1830+
if (attr_b) {
1831+
if (new_valid > data_size)
1832+
new_valid = data_size;
18301833

1831-
valid_size = le64_to_cpu(attr_b->nres.valid_size);
1832-
if (new_valid != valid_size) {
1833-
attr_b->nres.valid_size = cpu_to_le64(valid_size);
1834-
mi_b->dirty = true;
1834+
valid_size = le64_to_cpu(attr_b->nres.valid_size);
1835+
if (new_valid != valid_size) {
1836+
attr_b->nres.valid_size = cpu_to_le64(valid_size);
1837+
mi_b->dirty = true;
1838+
}
18351839
}
18361840

18371841
return err;

0 commit comments

Comments
 (0)