From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796167923; b=InkokdObWPKDHY7HDQ12EXBtLxlkQ/f3bCDp5PutNWzKV5pVFUatdW6J/CtEcw91QSGs mfgJZa5f8CxV4owKfCoPUjl50O5VUdhKPvuhBJLUm2dxiLX89B0FooSKQ4zk+34zYmp0y G0wh9bMotLwhHO/7pMEeF6gduTrktdRBN1dC0bCaa1zxuxj+zZ1MXPH16boxoALF/lPkm kQjyI8KoZUmcrDTmV0pwLaTSgqJLue8o45bLyTJT55gt8JPKwvvKakYX6p4J1rOPeIvIb bdP55pWvNwJux1Yi21kmrEloHXXMuqDE3HzFSfC/6RSy5HBuuwuOpk8StpGR1ELM/Pg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796167923; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=VCMhBPcWKfVAWMDRExI92iuRf0NoazgEhbyYpr7k4xM=; b=xt9PIlD4pSEvDD+8AyK0sC23qgoRmdKqFc7P2Ybi68Gzw143uqwCBCzJ8GZ6nPUqMVLB qkHyA8O4il4coRfzfI4rEZU0FCcK1fO+Zh75RIAU+ok1CkSlYRdGEjxkKRzHGGZR4gWN0 MUznquBKCQesTaAXnnswGuQ6QczJ0uRm9BQJNfm0lrKrnhlORhq/QIXIVLwSsnPgDUEiu gh0Rq4M1wejv242vdUhWQLeif04GgGTtSSk37w1EQQL2YYDngsoY6x4jqDDO8x30nDrSH GuxEitVcKipD/nSE84hIgawj76+bx4RCqkClLU3+uQHz+IoPv3523nKQMZ0U5URSs1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Ais4UAke; arc=none smtp.remote-ip=209.85.221.42 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA615606A686 for ; Tue, 1 Dec 2026 23:32:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DA615606A686 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Ais4UAke Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-4a9be758734so7883426f8f.1 for ; Tue, 01 Dec 2026 15:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796167921; x=1796772721; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=VCMhBPcWKfVAWMDRExI92iuRf0NoazgEhbyYpr7k4xM=; b=Ais4UAkebuBSnXuhfhKOLoBtaG+GgsS0tGSGkQuhkHUAihc5ScsruXnWDJ4WE3hpcO +ipdpnL6TMbCJvTqb/hioSC1cWfTpx/39uZvTXXFEyAqLMbxoUIdxrmNdXtlMOmo7vpC /9sU2nNG3JbM0L7rgd5cNXvMGKXl/2Fan19Km6Cb6dMJG653pvfCgVkXjhprsYnGy45k 8fNtie9YyuiUDKDenWbyIHPKpQDDMNJlV+hupAXGPtMjA3rXgmXP1egzC9oAcEnlS1ow 18Tgl0vQ2qf7M8hCx6X292TCqM1ZW8+o8CzklJ2RwV9EVumVTl2jhb1aeaIiG0s3JhCE KqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796167921; x=1796772721; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VCMhBPcWKfVAWMDRExI92iuRf0NoazgEhbyYpr7k4xM=; b=nQ0KkU0uIGcQnPGxBnFhaoApf5MirWf6eu65QaD8eti/XJoycQGzSeOk7mdtg6mb9i Z25TC/+SYfByV+MBNf+C//M2JMUCwJeQPIHDZNkrJRO9/hfy5KTCkJHnNrXwJtJYAWB/ 62K9hAT1jXFCW8UvPboZZTx123zah/QBg2FuqxG12FjH77JuyQKq1KHH8qXSJuWPUZo0 Me3d6KdGbeZvJ9jFNkW+vTVfyQeldpWt+VDr4k1ycz4PRsgXzHrQspvscI4FYY3shwaQ 9t0dIDI1Oic3SjnJnfLkX6fmCP39nKf4JhHRGhPjbtCF+ZbekhcDHOWgGERJT7omIOyX Tq3g== X-Forwarded-Encrypted: i=1; AL+hErHc0i13aWPQnUln+kGZXxoTgSrG7CrO8v3XqsWskOS2OARz/LC1het3HZ3++9SWZ9OdheuBmUdOks4F1io=@vger.kernel.org X-Gm-Message-State: APuU4Z9ke5cj1S2JBfQeFx/huBXeWHB2lebxHFbfg4+jteCpNHZYD3DZ Zcg+Hzn461y/WhxtLHYaYdArNwNNadHfcL3MsNKfMarzlNohY+4um3/I X-Gm-Gg: AZFdTZfh3KL8ZSp5evcsRJg1prDaektJ8CPMqS/ohd9VxjZq4B0IoGEbo0PSrDqlAHG 24Kn4+qi2tXNGDXUCXBUGUh17TPoOEEWlIKHNpqd+dtnz5xh5HAlGkzZ9DSHsl4E860cvk0T/o9 ShGEnOUgCzVzsz6LSbZwZhug4sCHvJXwowPe2r7bRAai0A8TjVTEJGWlH8uImErEsajpyu1kl0r 2mD28R0wGLhB2Uhh34JQwbExOuhsq+QuAJSIX64WWdmvrp3/WU5fVBt0UZIjP/cXTeFGZP3WHIG 8y05HoIbPg4NivkzPg2x1ER4gvbi4cHX1bv4je1wbIXRxjrU+LfaFkH45aF8kX/6dnjRBS9Mja6 YVPzkvaElGw4AXMUjNY7/OqpsAnnw1SWMHpvWulv6zgQifaHRJyXM82usPvuHnm9/ueS+Xv16e0 NOR78a0/vwqNP+e7N3ooMKzMeY6NnlPhIKzaB8rEJafrz1SEEyCQC2kjlx1HWH1tIt8xPfqIAs1 yoO7hAlqeMbV6VX02W7EBk6TN39ezxOhgd2a/i6S7llCclsDBwxM+Ioe9KS42d64mNkFvV7xmIO QmPJ+O/B7gxyx48Po+iu7NqyoQAaE4yAkcZ6e341l8m2x935 X-Received: by 2002:a05:6000:2c13:b0:491:fd47:5df3 with SMTP id ffacd0b85a97d-4abab02d216mr72668488f8f.7.1796167921297; Tue, 01 Dec 2026 15:32:01 -0800 (PST) Received: from [127.0.1.1] ([85.105.252.11]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a680483sm73983323f8f.28.2026.12.01.15.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 15:32:00 -0800 (PST) From: Bartu Alev Date: Wed, 02 Dec 2026 02:31:43 +0300 Subject: [PATCH 2/3] platform/asus: asus-wmi: Use __free(kfree) in asus_wmi_evaluate_method_buf() X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-asus-wmi-eval-buf-v1-2-640c12d437dc@gmail.com> References: <20261202-asus-wmi-eval-buf-v1-0-640c12d437dc@gmail.com> In-Reply-To: <20261202-asus-wmi-eval-buf-v1-0-640c12d437dc@gmail.com> To: Corentin Chary , "Luke D. Jones" , Denis Benato , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Bartu Alev X-Mailer: b4 0.15.2 Replace the manual kfree(obj) and the out_free: goto with a __free(kfree) cleanup attribute, as include/linux/cleanup.h asks not to mix goto with scope-based cleanup in the same routine. Declare the buffer right after the evaluation and before the ACPI_FAILURE(status) check, so that ownership is taken on every path. This also covers a leak inside ACPICA: acpi_evaluate_object() in nsxfeval.c allocates return_buffer->pointer through acpi_ut_initialize_buffer() and, if acpi_ut_copy_iobject_to_eobject() then fails with AE_TYPE or AE_SUPPORT (utcopy.c), returns without freeing it. The ACPI_FAILURE path now releases that buffer as well. Signed-off-by: Bartu Alev --- drivers/platform/asus/asus-wmi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/platform/asus/asus-wmi.c b/drivers/platform/asus/asus-wmi.c index 4f74fdfd7a0c2..015e207e840e6 100644 --- a/drivers/platform/asus/asus-wmi.c +++ b/drivers/platform/asus/asus-wmi.c @@ -477,11 +477,15 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, struct acpi_buffer input = { (acpi_size) sizeof(args), &args }; struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; acpi_status status; - union acpi_object *obj; u32 retval; int err = 0; status = asus_wmi_evaluate_method_locked(method_id, &input, &output); + /* + * Take ownership of the reply buffer right away: ACPICA may leave it + * allocated even when reporting a failure. + */ + union acpi_object *obj __free(kfree) = output.pointer; pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x\n", __func__, method_id, arg0, arg1); @@ -491,15 +495,14 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, return -EIO; } - obj = (union acpi_object *)output.pointer; - /* * acpi_evaluate_object() reports AE_OK with a NULL buffer when the * method returned no object at all. */ if (!obj) { - err = -ENODATA; - goto out_free; + pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n", + __func__, method_id, arg0, -ENODATA); + return -ENODATA; } switch (obj->type) { @@ -533,9 +536,6 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, break; } -out_free: - kfree(obj); - if (err) { pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n", __func__, method_id, arg0, err); -- 2.56.1