Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a0d12ef authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Rafael J. Wysocki
Browse files

ACPI / scan: use kstrdup_const() in acpi_add_id()



Empirically, acpi_add_id is mostly called with string literals, so
using kstrdup_const for initializing struct acpi_hardware_id::id saves
a little run-time memory and a string copy.

Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 844142c3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1184,7 +1184,7 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
	if (!id)
		return;

	id->id = kstrdup(dev_id, GFP_KERNEL);
	id->id = kstrdup_const(dev_id, GFP_KERNEL);
	if (!id->id) {
		kfree(id);
		return;
@@ -1322,7 +1322,7 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
	struct acpi_hardware_id *id, *tmp;

	list_for_each_entry_safe(id, tmp, &pnp->ids, list) {
		kfree(id->id);
		kfree_const(id->id);
		kfree(id);
	}
	kfree(pnp->unique_id);