From patchwork Thu Nov 9 06:22:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongfeng Wang X-Patchwork-Id: 10050167 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 66022601EA for ; Thu, 9 Nov 2017 06:31:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 590CE2AA4C for ; Thu, 9 Nov 2017 06:31:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D7102AB26; Thu, 9 Nov 2017 06:31:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20A872AA4C for ; Thu, 9 Nov 2017 06:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751194AbdKIGbA (ORCPT ); Thu, 9 Nov 2017 01:31:00 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:10039 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750979AbdKIGa7 (ORCPT ); Thu, 9 Nov 2017 01:30:59 -0500 Received: from 172.30.72.60 (EHLO DGGEMS412-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DKP23640; Thu, 09 Nov 2017 14:30:50 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.361.1; Thu, 9 Nov 2017 14:30:42 +0800 From: Xiongfeng Wang To: CC: , , , , Subject: [PATCH] ACPI / utils: Fix memory leak on an error return path in acpi_evaluate_reference() Date: Thu, 9 Nov 2017 14:22:39 +0800 Message-ID: <1510208559-36069-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0204.5A03F61A.0153, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 431c2fde35965979028b0160fbed6b1c Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When package.count is larger than ACPI_MAS_HANDLES, buffer.pointer is not freed before the function returns AE_NO_MEMORY. Fix this possible memory leak by kfree'ing it. Signed-off-by: Xiongfeng Wang --- drivers/acpi/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index b9d956c..9282549 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -355,6 +355,7 @@ } if (package->package.count > ACPI_MAX_HANDLES) { + kfree(package); return AE_NO_MEMORY; } list->count = package->package.count;