mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] acpi: Fix memory leak on acpi_scan_init_hotplug() error path
@ 2013-05-15 16:49 Catalin Marinas
  2013-05-15 18:21 ` Toshi Kani
  0 siblings, 1 reply; 3+ messages in thread
From: Catalin Marinas @ 2013-05-15 16:49 UTC (permalink / raw)
  To: Len Brown, Rafael J. Wysocki
  Cc: linux-acpi, linux-kernel, Toshi Kani, Larry Finger

Following commit 6b772e8f9 (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().

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Toshi Kani <toshi.kani@hp.com>
---
 drivers/acpi/scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index fe158fd..c1bc608 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1785,7 +1785,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
 	acpi_set_pnp_ids(handle, &pnp, type);
 
 	if (!pnp.type.hardware_id)
-		return;
+		goto out;
 
 	/*
 	 * 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)
 		}
 	}
 
+out:
 	acpi_free_pnp_ids(&pnp);
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-15 20:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-15 16:49 [PATCH] acpi: Fix memory leak on acpi_scan_init_hotplug() error path Catalin Marinas
2013-05-15 18:21 ` Toshi Kani
2013-05-15 20:48   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®