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:
 <BYAPR03MB4168E7E5A2616EB82D3883E8ADE02@BYAPR03MB4168.namprd03.prod.outlook.com>
Date: Sat, 11 May 2024 19:35:53 +0000
From: Jiasheng Jiang <jiashengjiangcool@...look.com>
To: rafael@...nel.org,
	lenb@...nel.org,
	lv.zheng@...el.com,
	rui.zhang@...el.com
Cc: linux-acpi@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Jiasheng Jiang <jiashengjiangcool@...look.com>
Subject: [PATCH] ACPI: scan: Add missing check for kstrdup()

Add check for the return value of kstrdup() in order to gurantee
the success of allocation.
Moreover, move the code forward to simplify the error handling.

Fixes: ccf78040265b ("ACPI: Add _UID support for ACPI devices.")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@...look.com>
---
 drivers/acpi/scan.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index d1464324de95..59246757a207 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1385,6 +1385,15 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
 			return;
 		}
 
+		if (info->valid & ACPI_VALID_UID) {
+			pnp->unique_id = kstrdup(info->unique_id.string,
+							GFP_KERNEL);
+			if (!pnp->unique_id) {
+				kfree(info);
+				return;
+			}
+		}
+
 		if (info->valid & ACPI_VALID_HID) {
 			acpi_add_id(pnp, info->hardware_id.string);
 			pnp->type.platform_id = 1;
@@ -1398,9 +1407,6 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
 			pnp->bus_address = info->address;
 			pnp->type.bus_address = 1;
 		}
-		if (info->valid & ACPI_VALID_UID)
-			pnp->unique_id = kstrdup(info->unique_id.string,
-							GFP_KERNEL);
 		if (info->valid & ACPI_VALID_CLS)
 			acpi_add_id(pnp, info->class_code.string);
 
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ