From patchwork Wed May 15 16:49:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 2574001 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0978EDF2A2 for ; Wed, 15 May 2013 16:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759551Ab3EOQ4R (ORCPT ); Wed, 15 May 2013 12:56:17 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:52406 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759180Ab3EOQ4R (ORCPT ); Wed, 15 May 2013 12:56:17 -0400 Received: from e102109-lin.cambridge.arm.com (e102109-lin.cambridge.arm.com [10.1.203.38]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id r4FGnehX022343; Wed, 15 May 2013 17:49:40 +0100 From: Catalin Marinas To: Len Brown , "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Toshi Kani , Larry Finger Subject: [PATCH] acpi: Fix memory leak on acpi_scan_init_hotplug() error path Date: Wed, 15 May 2013 17:49:35 +0100 Message-Id: <1368636575-5480-1-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 1.7.12.3 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 Reported-by: Larry Finger Cc: Toshi Kani Reviewed-by: Toshi Kani Tested-by: Toshi Kani --- drivers/acpi/scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); }