lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230922113923.3621959-1-make_ruc2021@163.com>
Date:   Fri, 22 Sep 2023 19:39:23 +0800
From:   Ma Ke <make_ruc2021@....com>
To:     davidgow@...gle.com
Cc:     linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com,
        linux-kernel@...r.kernel.org, Ma Ke <make_ruc2021@....com>
Subject: [PATCH v2] list: test: potential dereference of null pointer

To avoid the failure of alloc, we could check the return value of
kmalloc() and kzalloc().

Signed-off-by: Ma Ke <make_ruc2021@....com>
---
 lib/list-test.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/list-test.c b/lib/list-test.c
index 0cc27de9cec8..70e898976dbf 100644
--- a/lib/list-test.c
+++ b/lib/list-test.c
@@ -27,9 +27,18 @@ static void list_test_list_init(struct kunit *test)
 	INIT_LIST_HEAD(&list2);
 
 	list4 = kzalloc(sizeof(*list4), GFP_KERNEL | __GFP_NOFAIL);
+	if (!list4) {
+		KUNIT_FAIL(test, "Initialising list4 failed.\n");
+		return;
+	}
 	INIT_LIST_HEAD(list4);
 
 	list5 = kmalloc(sizeof(*list5), GFP_KERNEL | __GFP_NOFAIL);
+	if (!list5) {
+		kfree(list4);
+		KUNIT_FAIL(test, "Initialising list5 failed.\n");
+		return;
+	}
 	memset(list5, 0xFF, sizeof(*list5));
 	INIT_LIST_HEAD(list5);
 
-- 
2.37.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ