提交 7a26b530 编写于 作者: C Catalin Marinas 提交者: Rafael J. Wysocki

ACPI / scan: Fix memory leak on acpi_scan_init_hotplug() error path

Following commit 6b772e8f (ACPI: Update PNPID match handling for
notify), the acpi_scan_init_hotplug() calls acpi_set_pnp_ids() which
allocates acpi_hardware_id and copies a few strings (kstrdup). If the
devices does not have hardware_id set, the function exits without
freeing the previously allocated ids (and kmemleak complains). This
patch calls simply changes 'return' on error to a 'goto out' which
calls acpi_free_pnp_ids().
Reported-by: NLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
Reviewed-by: NToshi Kani <toshi.kani@hp.com>
Tested-by: NToshi Kani <toshi.kani@hp.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 0ab5bb64
...@@ -1785,7 +1785,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type) ...@@ -1785,7 +1785,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
acpi_set_pnp_ids(handle, &pnp, type); acpi_set_pnp_ids(handle, &pnp, type);
if (!pnp.type.hardware_id) if (!pnp.type.hardware_id)
return; goto out;
/* /*
* This relies on the fact that acpi_install_notify_handler() will not * This relies on the fact that acpi_install_notify_handler() will not
...@@ -1800,6 +1800,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type) ...@@ -1800,6 +1800,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
} }
} }
out:
acpi_free_pnp_ids(&pnp); acpi_free_pnp_ids(&pnp);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册