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>] [day] [month] [year] [list]
Message-ID: <0b2bccfb-d1a3-4c2e-b1d3-159630edf21a@web.de>
Date: Tue, 23 Jan 2024 18:38:42 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: devicetree@...r.kernel.org, kernel-janitors@...r.kernel.org,
 Frank Rowand <frowand.list@...il.com>, Lizhi Hou <lizhi.hou@....com>,
 Rob Herring <robh+dt@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>, Kunwu Chan <chentao@...inos.cn>
Subject: [PATCH] of: unittest: Return directly after a failed kasprintf() call
 in of_unittest_pci_node_verify()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 23 Jan 2024 18:24:53 +0100

The result from a call of the function “kasprintf” was passed to
a subsequent function call without checking for a null pointer before
(according to a memory allocation failure).
This issue was detected by using the Coccinelle software.

Thus return directly after a failed kasprintf() call.

Fixes: 26409dd045892 ("of: unittest: Add pci_dt_testdrv pci driver")
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/of/unittest.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index e9e90e96600e..a46268fe8d2a 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3990,6 +3990,9 @@ static int of_unittest_pci_node_verify(struct pci_dev *pdev, bool add)

 	if (add) {
 		path = kasprintf(GFP_KERNEL, "%pOF/pci-ep-bus@...nittest-pci@100", pnp);
+		if (!path)
+			return -ENOMEM;
+
 		np = of_find_node_by_path(path);
 		unittest(np, "Failed to get unittest-pci node under PCI node\n");
 		if (!np) {
@@ -4003,6 +4006,9 @@ static int of_unittest_pci_node_verify(struct pci_dev *pdev, bool add)
 			rc = -ENODEV;
 	} else {
 		path = kasprintf(GFP_KERNEL, "%pOF/pci-ep-bus@0", pnp);
+		if (!path)
+			return -ENOMEM;
+
 		np = of_find_node_by_path(path);
 		unittest(!np, "Child device tree node is not removed\n");
 		child_dev = device_find_any_child(&pdev->dev);
--
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ