From patchwork Thu Dec 19 12:38:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 3379551 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D95AD9F314 for ; Thu, 19 Dec 2013 12:43:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 525CD20649 for ; Thu, 19 Dec 2013 12:43:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2EAF2052A for ; Thu, 19 Dec 2013 12:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756826Ab3LSMm5 (ORCPT ); Thu, 19 Dec 2013 07:42:57 -0500 Received: from mga09.intel.com ([134.134.136.24]:19259 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756809Ab3LSMm4 (ORCPT ); Thu, 19 Dec 2013 07:42:56 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 19 Dec 2013 04:39:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,512,1384329600"; d="scan'208";a="427187558" Received: from gerry-dev.bj.intel.com ([10.238.158.74]) by orsmga001.jf.intel.com with ESMTP; 19 Dec 2013 04:42:53 -0800 From: Jiang Liu To: "Rafael J . Wysocki" , Bjorn Helgaas , Lv Zheng , Len Brown Cc: Jiang Liu , Tony Luck , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [Patch v2 03/13] PCI, pci-label: release allocated ACPI object on error recovery path Date: Thu, 19 Dec 2013 20:38:12 +0800 Message-Id: <1387456702-4709-4-git-send-email-jiang.liu@linux.intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387456702-4709-1-git-send-email-jiang.liu@linux.intel.com> References: <1387456702-4709-1-git-send-email-jiang.liu@linux.intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Function dsm_get_label() leaks the returned ACPI object if obj->package.count is not 2, so fix the possible memory leak. Signed-off-by: Jiang Liu --- drivers/pci/pci-label.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c index d51f45a..f6e01a5 100644 --- a/drivers/pci/pci-label.c +++ b/drivers/pci/pci-label.c @@ -233,11 +233,7 @@ dsm_get_label(acpi_handle handle, int func, return -1; obj = (union acpi_object *)output->pointer; - - switch (obj->type) { - case ACPI_TYPE_PACKAGE: - if (obj->package.count != 2) - break; + if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2) { len = obj->package.elements[0].integer.value; if (buf) { if (attribute == ACPI_ATTR_INDEX_SHOW) @@ -250,10 +246,10 @@ dsm_get_label(acpi_handle handle, int func, } kfree(output->pointer); return len; - break; - default: - kfree(output->pointer); } + + kfree(output->pointer); + return -1; }