Commit aaab47f2 authored by Konstantin Komarov's avatar Konstantin Komarov

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: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent d6ca2d25
...@@ -1743,8 +1743,10 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, ...@@ -1743,8 +1743,10 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
le_b = NULL; le_b = NULL;
attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL,
0, NULL, &mi_b); 0, NULL, &mi_b);
if (!attr_b) if (!attr_b) {
return -ENOENT; err = -ENOENT;
goto out;
}
attr = attr_b; attr = attr_b;
le = le_b; le = le_b;
...@@ -1825,6 +1827,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, ...@@ -1825,6 +1827,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
ok: ok:
run_truncate_around(run, vcn); run_truncate_around(run, vcn);
out: out:
if (attr_b) {
if (new_valid > data_size) if (new_valid > data_size)
new_valid = data_size; new_valid = data_size;
...@@ -1833,6 +1836,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, ...@@ -1833,6 +1836,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
attr_b->nres.valid_size = cpu_to_le64(valid_size); attr_b->nres.valid_size = cpu_to_le64(valid_size);
mi_b->dirty = true; mi_b->dirty = true;
} }
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment