Blame SOURCES/0024-fs-ntfs3-Potential-NULL-dereference-in-hdr_find_spli.patch

Kmods SIG 8b815c
From 8c83a4851da1c7eda83098ade238665b15774da3 Mon Sep 17 00:00:00 2001
Kmods SIG 8b815c
From: Dan Carpenter <dan.carpenter@oracle.com>
Kmods SIG 8b815c
Date: Tue, 24 Aug 2021 10:50:15 +0300
Kmods SIG 8b815c
Subject: [Backport 8c83a4851da1] src: Potential NULL dereference in
Kmods SIG 8b815c
 hdr_find_split()
Kmods SIG 8b815c
Kmods SIG 8b815c
The "e" pointer is dereferenced before it has been checked for NULL.
Kmods SIG 8b815c
Move the dereference after the NULL check to prevent an Oops.
Kmods SIG 8b815c
Kmods SIG 8b815c
Fixes: 82cae269cfa9 ("src: Add initialization of super block")
Kmods SIG 8b815c
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Kmods SIG 8b815c
Reviewed-by: Kari Argillander <kari.argillander@gmail.com>
Kmods SIG 8b815c
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Kmods SIG 8b815c
---
Kmods SIG 8b815c
 src/index.c | 3 ++-
Kmods SIG 8b815c
 1 file changed, 2 insertions(+), 1 deletion(-)
Kmods SIG 8b815c
Kmods SIG 8b815c
diff --git a/src/index.c b/src/index.c
Kmods SIG 8b815c
index 5fb41c9c89100aee4d6d0e8f7cf65556aec11250..f4729aa50671f27de961305744b3839588696108 100644
Kmods SIG 8b815c
--- a/src/index.c
Kmods SIG 8b815c
+++ b/src/index.c
Kmods SIG 8b815c
@@ -557,11 +557,12 @@ static const struct NTFS_DE *hdr_find_split(const struct INDEX_HDR *hdr)
Kmods SIG 8b815c
 	size_t o;
Kmods SIG 8b815c
 	const struct NTFS_DE *e = hdr_first_de(hdr);
Kmods SIG 8b815c
 	u32 used_2 = le32_to_cpu(hdr->used) >> 1;
Kmods SIG 8b815c
-	u16 esize = le16_to_cpu(e->size);
Kmods SIG 8b815c
+	u16 esize;
Kmods SIG 8b815c
 
Kmods SIG 8b815c
 	if (!e || de_is_last(e))
Kmods SIG 8b815c
 		return NULL;
Kmods SIG 8b815c
 
Kmods SIG 8b815c
+	esize = le16_to_cpu(e->size);
Kmods SIG 8b815c
 	for (o = le32_to_cpu(hdr->de_off) + esize; o < used_2; o += esize) {
Kmods SIG 8b815c
 		const struct NTFS_DE *p = e;
Kmods SIG 8b815c
 
Kmods SIG 8b815c
-- 
Kmods SIG 8b815c
2.31.1
Kmods SIG 8b815c