From patchwork Mon Nov 21 05:54:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Ma X-Patchwork-Id: 1707033 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=pUmRfAJU; 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 4NFxRj2pTvz23nR for ; Mon, 21 Nov 2022 16:54:41 +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 1owzlM-0004A1-0A; Mon, 21 Nov 2022 05:54:36 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1owzlF-0003zf-Vc for kernel-team@lists.ubuntu.com; Mon, 21 Nov 2022 05:54:29 +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-0.canonical.com (Postfix) with ESMTPSA id 5D1693FE1A for ; Mon, 21 Nov 2022 05:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1669010068; bh=H6EAu9MJrXJv1VDMBx2t8DVdiGMyk9pKYl/m1Jb/Ck0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pUmRfAJUP9m55vo3n1H31JPS4/mmvteyzEDg81n91ARAs9VtqVkxjBED0hFy3jX9J S/7bsnwZDBTe4RNvVsSMFzACYA1wDlk3A/kC7ar3W8VhZ1Pa4WySH+K6vdMZHQD0+I jJVSjAoIfxbFDBWlPRWB/xqcn60utrylozD4M6vKM6EjJCKeong1YTkRpt26raDsip gQnf9wD6WL8nDilPCY6GL3jogAhAjRNJFqKa8Q9lOuChHMqOKug4wSYO4tR1aFCDhg y+CG1ftwhWIvJmr/WgIAxW6B33No6YpF+b2vn0rt4KyyZiQTI+TVoeRrsc3k+eyNDc miOQ336woJpeQ== From: Aaron Ma To: kernel-team@lists.ubuntu.com Subject: [OEM-5.17][PATCH 4/4] wifi: mt76: mt7921: fix use after free in mt7921_acpi_read() Date: Mon, 21 Nov 2022 13:54:12 +0800 Message-Id: <20221121055412.3744-5-aaron.ma@canonical.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121055412.3744-1-aaron.ma@canonical.com> References: <20221121055412.3744-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 */