Commit 8c83a485 authored by Dan Carpenter's avatar Dan Carpenter Committed by Konstantin Komarov

fs/ntfs3: Potential NULL dereference in hdr_find_split()

The "e" pointer is dereferenced before it has been checked for NULL.
Move the dereference after the NULL check to prevent an Oops.

Fixes: 82cae269 ("fs/ntfs3: Add initialization of super block")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarKari Argillander <kari.argillander@gmail.com>
Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent 04810f00
...@@ -557,11 +557,12 @@ static const struct NTFS_DE *hdr_find_split(const struct INDEX_HDR *hdr) ...@@ -557,11 +557,12 @@ static const struct NTFS_DE *hdr_find_split(const struct INDEX_HDR *hdr)
size_t o; size_t o;
const struct NTFS_DE *e = hdr_first_de(hdr); const struct NTFS_DE *e = hdr_first_de(hdr);
u32 used_2 = le32_to_cpu(hdr->used) >> 1; u32 used_2 = le32_to_cpu(hdr->used) >> 1;
u16 esize = le16_to_cpu(e->size); u16 esize;
if (!e || de_is_last(e)) if (!e || de_is_last(e))
return NULL; return NULL;
esize = le16_to_cpu(e->size);
for (o = le32_to_cpu(hdr->de_off) + esize; o < used_2; o += esize) { for (o = le32_to_cpu(hdr->de_off) + esize; o < used_2; o += esize) {
const struct NTFS_DE *p = e; const struct NTFS_DE *p = e;
......
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