From patchwork Fri Sep 4 07:00:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaotian Feng X-Patchwork-Id: 45563 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8477fK2000685 for ; Fri, 4 Sep 2009 07:07:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932985AbZIDHAK (ORCPT ); Fri, 4 Sep 2009 03:00:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933005AbZIDHAJ (ORCPT ); Fri, 4 Sep 2009 03:00:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53119 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932722AbZIDHAF (ORCPT ); Fri, 4 Sep 2009 03:00:05 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n84706NA031254; Fri, 4 Sep 2009 03:00:06 -0400 Received: from localhost.localdomain (dhcp-65-132.nay.redhat.com [10.66.65.132]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n84702mG008758; Fri, 4 Sep 2009 03:00:03 -0400 From: Xiaotian Feng To: len.brown@intel.com, rui.zhang@intel.com, yakui.zhao@intel.com, bjorn.helgaas@hp.com, ak@linux.intel.com Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaotian Feng Subject: [PATCH] drivers/acpi: fix memory leak in acpi_device_set_id Date: Fri, 4 Sep 2009 15:00:19 +0800 Message-Id: <1252047619-2924-1-git-send-email-dfeng@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In acpi_device_set_id, if cid_list is allocated by ACPI_ALLOCATE_ZEROED, it is never freed. This patch fixes the memory leak. Signed-off-by: Xiaotian Feng --- drivers/acpi/scan.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 781435d..a0102ad 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1010,6 +1010,7 @@ static void acpi_device_set_id(struct acpi_device *device, struct acpi_compatible_id_list *cid_list = NULL; const char *cid_add = NULL; acpi_status status; + int free_cid_list = 0; switch (type) { case ACPI_BUS_TYPE_DEVICE: @@ -1098,6 +1099,7 @@ static void acpi_device_set_id(struct acpi_device *device, kfree(buffer.pointer); return; } else { + free_cid_list = 1; cid_list->count = 0; cid_list->size = size; } @@ -1124,6 +1126,8 @@ static void acpi_device_set_id(struct acpi_device *device, printk(KERN_ERR PREFIX "Memory allocation error\n"); } + if (free_cid_list) + ACPI_FREE(cid_list); kfree(buffer.pointer); }