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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231204062245.2453512-1-chentao@kylinos.cn>
Date:   Mon,  4 Dec 2023 14:22:45 +0800
From:   Kunwu Chan <chentao@...inos.cn>
To:     bhelgaas@...gle.com, lizhi.hou@....com, robh@...nel.org
Cc:     kunwu.chan@...mail.com, linux-pci@...r.kernel.org,
        linux-kernel@...r.kernel.org, Kunwu Chan <chentao@...inos.cn>
Subject: [PATCH] PCI: Fix null pointer dereference in of_pci_prop_compatible

kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.

Fixes: 407d1a51921e ("PCI: Create device tree node for bridge")
Signed-off-by: Kunwu Chan <chentao@...inos.cn>
---
 drivers/pci/of_property.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
index c2c7334152bc..5e16bbff3ba4 100644
--- a/drivers/pci/of_property.c
+++ b/drivers/pci/of_property.c
@@ -304,6 +304,11 @@ static int of_pci_prop_compatible(struct pci_dev *pdev,
 	compat_strs[PROP_COMPAT_PCICLASS_CCSS] =
 		kasprintf(GFP_KERNEL, "pciclass,%04x", pdev->class >> 8);
 
+	if (!compat_strs[PROP_COMPAT_PCI_VVVV_DDDD] ||
+	    !compat_strs[PROP_COMPAT_PCICLASS_CCSSPP] ||
+	    !compat_strs[PROP_COMPAT_PCICLASS_CCSS])
+		return -ENOMEM;
+
 	ret = of_changeset_add_prop_string_array(ocs, np, "compatible",
 						 compat_strs, PROP_COMPAT_NUM);
 	for (i = 0; i < PROP_COMPAT_NUM; i++)
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ