From patchwork Tue Nov 22 11:29:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 24322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2160619wrr; Tue, 22 Nov 2022 04:08:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf7RiAyG4JpRkqNQ6LBvsqNA77TSlS1J13Z5TC190iUfzefz2H4J+Op8BeudRyO+dOIZhyQX X-Received: by 2002:a17:90a:ab84:b0:213:343:9873 with SMTP id n4-20020a17090aab8400b0021303439873mr31288764pjq.102.1669118904308; Tue, 22 Nov 2022 04:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669118904; cv=none; d=google.com; s=arc-20160816; b=cIyL/WIjoywHwIWzcxcFNBmXCDPMKu9Yz8o+AhOpfNmVMvqwN4myCzrNei4rVkQtaN xBPHjqfGgPK/E4B7QAyVLX+87H6BZpcloIiJ2DoL2VSIcQlcjO3XEL7HjqdwognxhXxe qMglSMehLBzUZ9peGvV9MGtaa6/itbuBLcCgfAVgAflab9kSTILjHMI8yZDOpjaGwmeP l4/q3aWgx08eE92+w+uVLtpYg2ikoEdCzmfHcLvfOv66ZBysWoKgzAjYkstE6maDA4HW LpQEDrHsre2Ug5WMfxxzIOFPmJ6eSW1O4TzzMwgNWmBxYkAPYBM4Yt9GrJKGpbnlFWyT gyZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=ywmwUWWedVN6g0bGYwhkg9Dx9V0ssr2X6bST05IHHVA=; b=pNPehr0x/aEzPirefoO/pHeMY7e1ifWe2FSNu9Po570AoypK1HNF29xEupncQ5HDBB yncl66OJIWPjiWHOTL4wKeI3d7NN+7lFI5Ro1iNSwEb7/pmWv46a/vFY4cAwtJ0MiGMM df0P25ShoOEIMVWjNwIKpM6wSAs3aqfKA/1bRxngTYi4r6PSx6iHGWFsT20xTvA5xUrr jZr41EZnkbBoG7m+Rx8NKiEVKmJILJArcPqhiqbRvTyaFWrIZrzqTNXvM9ZwVL1vF2wU qGxCBpJmLxZqXB4XnYDZgXadAEsKpYJE/zObBFTHQ3EYv+yXaVD+LzxXUmqS289S9U13 rWNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a170902f60f00b00178431e112asi13692886plg.449.2022.11.22.04.08.10; Tue, 22 Nov 2022 04:08:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233538AbiKVLqU (ORCPT + 99 others); Tue, 22 Nov 2022 06:46:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233540AbiKVLpr (ORCPT ); Tue, 22 Nov 2022 06:45:47 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57AE512D1C; Tue, 22 Nov 2022 03:45:18 -0800 (PST) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NGj985QVczmW4h; Tue, 22 Nov 2022 19:44:44 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 22 Nov 2022 19:45:14 +0800 Received: from linux-ibm.site (10.175.102.37) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 22 Nov 2022 19:45:14 +0800 From: Hanjun Guo To: Eric Auger , Alex Williamson CC: , , Sinan Kaya , Hanjun Guo Subject: [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak Date: Tue, 22 Nov 2022 19:29:58 +0800 Message-ID: <1669116598-25761-1-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750198024057465954?= X-GMAIL-MSGID: =?utf-8?q?1750198024057465954?= The ACPI buffer memory (buffer.pointer) returned by acpi_evaluate_object() is not used after the call of _RST method, so it leads to memory leak. For the calling of ACPI _RST method, we don't need to pass a buffer for acpi_evaluate_object(), we can just pass NULL and remove the ACPI buffer memory in vfio_platform_acpi_call_reset(), then we don't need to free the memory and no memory leak. Fixes: d30daa33ec1d ("vfio: platform: call _RST method when using ACPI") Signed-off-by: Hanjun Guo Reviewed-by: Eric Auger --- drivers/vfio/platform/vfio_platform_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 55dc4f4..1a0a238 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -72,12 +72,11 @@ static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev, const char **extra_dbg) { #ifdef CONFIG_ACPI - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct device *dev = vdev->device; acpi_handle handle = ACPI_HANDLE(dev); acpi_status acpi_ret; - acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, &buffer); + acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, NULL); if (ACPI_FAILURE(acpi_ret)) { if (extra_dbg) *extra_dbg = acpi_format_exception(acpi_ret);