From patchwork Fri Jan 24 16:20:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 23680 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EFC4320307 for ; Fri, 24 Jan 2014 16:21:06 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id vb8sf11858980obc.6 for ; Fri, 24 Jan 2014 08:21:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=rVqsXRofQw5UwmjXxvm1aA4HWo+xyis+tisVme//euw=; b=mqIIiHI819pn0WEi3kfgr0VVO9RF0hfX/xDtGfwho6sxee77HjZVpsk8bT8jNeJGez OVGsf/9lyYPEI9++dP6m8f8Kviigd0c5poq99CcmYfXZaaJ1SVu2QvepPI4nfr2G561n xq5bEevg+lSd6V7Czu0u7aT3SenGYHivc6rZGcaK7p7g7okJjfya3HLbaiKWBxfjuNkW bJtNyNlMWCSJYT6FstYurPBezoLQaV2kKP0If65modQ64tsNxUF1c+fv/CUQK0y2ASQQ j217XRHlbHwc7hbzZ+kQpuqbdBjpyWgu6vELCwarRgVV8KRuu5BWT+wv7fMkNwx+QtWw lfVQ== X-Gm-Message-State: ALoCoQkyM5U0aX4P5f1GjUa+ZFVN5JnC+trXIYoXv8Io6ZsoM0z6wZ/+b4lFxEi44kquoyUljaTg X-Received: by 10.182.223.18 with SMTP id qq18mr5454846obc.33.1390580466053; Fri, 24 Jan 2014 08:21:06 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.69 with SMTP id n63ls565108qge.96.gmail; Fri, 24 Jan 2014 08:21:05 -0800 (PST) X-Received: by 10.58.200.168 with SMTP id jt8mr8213280vec.30.1390580465889; Fri, 24 Jan 2014 08:21:05 -0800 (PST) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id x5si787682veb.35.2014.01.24.08.21.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Jan 2014 08:21:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id p14so1932317vbm.25 for ; Fri, 24 Jan 2014 08:21:05 -0800 (PST) X-Received: by 10.220.110.210 with SMTP id o18mr47663vcp.49.1390580465813; Fri, 24 Jan 2014 08:21:05 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp114112vcz; Fri, 24 Jan 2014 08:21:05 -0800 (PST) X-Received: by 10.68.133.229 with SMTP id pf5mr15324389pbb.115.1390580465040; Fri, 24 Jan 2014 08:21:05 -0800 (PST) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by mx.google.com with ESMTPS id oq9si1649426pac.267.2014.01.24.08.21.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Jan 2014 08:21:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.43 is neither permitted nor denied by best guess record for domain of hanjun.guo@linaro.org) client-ip=209.85.220.43; Received: by mail-pa0-f43.google.com with SMTP id rd3so3451286pab.2 for ; Fri, 24 Jan 2014 08:21:04 -0800 (PST) X-Received: by 10.68.197.133 with SMTP id iu5mr15347538pbc.132.1390580464095; Fri, 24 Jan 2014 08:21:04 -0800 (PST) Received: from localhost ([39.181.43.174]) by mx.google.com with ESMTPSA id e6sm4561666pbg.4.2014.01.24.08.21.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 24 Jan 2014 08:21:03 -0800 (PST) From: Hanjun Guo To: Lv Zheng , Robert Moore Cc: "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, devel@acpica.org, patches@linaro.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Hanjun Guo , Yijing Wang Subject: [PATCH 2/2] ACPI / ACPICA: Fix potential memory leak in acpi_evaluate_object() Date: Sat, 25 Jan 2014 00:20:07 +0800 Message-Id: <1390580407-14525-2-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1390580407-14525-1-git-send-email-hanjun.guo@linaro.org> References: <1390580407-14525-1-git-send-email-hanjun.guo@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There is a potential memory leak when acpi_ut_copy_iobject_to_eobject() failed, because return_buffer was allocated in acpi_ut_initialize_buffer() when buffer type is ACPI_ALLOCATE_BUFFER or ACPI_ALLOCATE_LOCAL_BUFFER, and will not be freed outside when the return value is not AE_OK for acpi_evaluate_object(), fix it. Signed-off-by: Hanjun Guo Signed-off-by: Yijing Wang --- drivers/acpi/acpica/nsxfeval.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index a1b0b88..8ad792b 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c @@ -424,6 +424,11 @@ acpi_evaluate_object(acpi_handle handle, status = acpi_ut_copy_iobject_to_eobject( info->return_object, return_buffer); + if (ACPI_FAILURE(status) && + (buffer_space_needed == ACPI_ALLOCATE_BUFFER || + buffer_space_needed == ACPI_ALLOCATE_LOCAL_BUFFER)) { + ACPI_FREE(return_buffer); + } } }