From patchwork Mon Nov 21 05:53:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Ma X-Patchwork-Id: 1707027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=DBoEaljQ; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NFxR82MHKz23nV for ; Mon, 21 Nov 2022 16:54:12 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1owzkr-0003MX-AS; Mon, 21 Nov 2022 05:54:05 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1owzkm-0003EH-3B for kernel-team@lists.ubuntu.com; Mon, 21 Nov 2022 05:54:00 +0000 Received: from localhost.localdomain (unknown [222.129.35.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 4A28141D17 for ; Mon, 21 Nov 2022 05:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1669010039; bh=H6EAu9MJrXJv1VDMBx2t8DVdiGMyk9pKYl/m1Jb/Ck0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DBoEaljQLe2YL26ANFEwlxHmKWjLsht2MBvEH8efDbQ9Ef+xHvK8eDhR04EalSn8k 76v1YNsxI0LB1ASMf09JAZjzpA4R6fpAP2ERVx79N0YYNUNbDW3dTxY/MeA885Fqn2 narNzKQVWoK8c6KzzZIz0akCWeIFeDjrD/gciYnu2vwo7JXHc/naxJKWr0AeEBPOd+ /b3JEY/NtWO2HnknW4z6oCBcPdCBOmTUF2t3oftAO6uZxbeXfjEF2iAP/5nL+x9lDW pkLRpRYUjgnooa4vO6j3WMrOHR3jLm+YzKjnnxRlzwK82Px33a3I6YBQGASN/UgElO 6OxwsEpQE1Ajw== From: Aaron Ma To: kernel-team@lists.ubuntu.com Subject: [J][PATCH 8/8] wifi: mt76: mt7921: fix use after free in mt7921_acpi_read() Date: Mon, 21 Nov 2022 13:53:35 +0800 Message-Id: <20221121055335.3714-9-aaron.ma@canonical.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121055335.3714-1-aaron.ma@canonical.com> References: <20221121055335.3714-1-aaron.ma@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dan Carpenter BugLink: https://bugs.launchpad.net/bugs/1997200 Don't dereference "sar_root" after it has been freed. Fixes: f965333e491e ("mt76: mt7921: introduce ACPI SAR support") Signed-off-by: Dan Carpenter Signed-off-by: Felix Fietkau (cherry picked from commit e7de4b4979bd8d313ec837931dde936653ca82ea) Signed-off-by: Aaron Ma --- drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c b/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c index be4f07ad3af91..47e034a9b0037 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c @@ -13,6 +13,7 @@ mt7921_acpi_read(struct mt7921_dev *dev, u8 *method, u8 **tbl, u32 *len) acpi_handle root, handle; acpi_status status; u32 i = 0; + int ret; root = ACPI_HANDLE(mdev->dev); if (!root) @@ -52,9 +53,11 @@ mt7921_acpi_read(struct mt7921_dev *dev, u8 *method, u8 **tbl, u32 *len) *(*tbl + i) = (u8)sar_unit->integer.value; } free: + ret = (i == sar_root->package.count) ? 0 : -EINVAL; + kfree(sar_root); - return (i == sar_root->package.count) ? 0 : -EINVAL; + return ret; } /* MTCL : Country List Table for 6G band */