[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250811082223.377017-1-liaoyuanhong@vivo.com>
Date: Mon, 11 Aug 2025 16:22:23 +0800
From: Liao Yuanhong <liaoyuanhong@...o.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>,
Len Brown <lenb@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
linux-acpi@...r.kernel.org (open list:ACPI),
linux-pci@...r.kernel.org (open list:PCI SUBSYSTEM),
linux-kernel@...r.kernel.org (open list)
Cc: Liao Yuanhong <liaoyuanhong@...o.com>
Subject: [PATCH] PCI: acpiphp_ibm: Using kmemdup() to simplify code
Use kmemdup() to replace the original code's allocate-and-copy operations.
It enhances code readability and simplifies nested conditionals.
Signed-off-by: Liao Yuanhong <liaoyuanhong@...o.com>
---
drivers/pci/hotplug/acpiphp_ibm.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 18e01cd55a8e..6a16c8e8238f 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -140,11 +140,8 @@ static union apci_descriptor *ibm_slot_from_id(int id)
ret = des;
ibm_slot_done:
- if (ret) {
- ret = kmalloc(sizeof(union apci_descriptor), GFP_KERNEL);
- if (ret)
- memcpy(ret, des, sizeof(union apci_descriptor));
- }
+ if (ret)
+ ret = kmemdup(des, sizeof(union apci_descriptor), GFP_KERNEL);
kfree(table);
return ret;
}
--
2.34.1
Powered by blists - more mailing lists