Skip to content

Commit af5cab0

Browse files
Andrey Vatoropinaalexandrovich
authored andcommitted
fs/ntfs3: handle hdr_first_de() return value
The hdr_first_de() function returns a pointer to a struct NTFS_DE. This pointer may be NULL. To handle the NULL error effectively, it is important to implement an error handler. This will help manage potential errors consistently. Additionally, error handling for the return value already exists at other points where this function is called. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 82cae26 ("fs/ntfs3: Add initialization of super block") Signed-off-by: Andrey Vatoropin <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 4665a0d commit af5cab0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/ntfs3/index.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,10 @@ static int indx_get_entry_to_replace(struct ntfs_index *indx,
21822182

21832183
e = hdr_first_de(&n->index->ihdr);
21842184
fnd_push(fnd, n, e);
2185+
if (!e) {
2186+
err = -EINVAL;
2187+
goto out;
2188+
}
21852189

21862190
if (!de_is_last(e)) {
21872191
/*
@@ -2203,6 +2207,10 @@ static int indx_get_entry_to_replace(struct ntfs_index *indx,
22032207

22042208
n = fnd->nodes[level];
22052209
te = hdr_first_de(&n->index->ihdr);
2210+
if (!te) {
2211+
err = -EINVAL;
2212+
goto out;
2213+
}
22062214
/* Copy the candidate entry into the replacement entry buffer. */
22072215
re = kmalloc(le16_to_cpu(te->size) + sizeof(u64), GFP_NOFS);
22082216
if (!re) {

0 commit comments

Comments
 (0)