From patchwork Mon Nov 21 05:55:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Ma X-Patchwork-Id: 1707038 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=Uu9J8K0Y; 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 4NFxTK1lCzz23nP for ; Mon, 21 Nov 2022 16:56:05 +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 1owzmi-0006KP-2m; Mon, 21 Nov 2022 05:56:00 +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 1owzme-0006GA-Dn for kernel-team@lists.ubuntu.com; Mon, 21 Nov 2022 05:55:56 +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 CAC7241D17 for ; Mon, 21 Nov 2022 05:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1669010155; bh=H6EAu9MJrXJv1VDMBx2t8DVdiGMyk9pKYl/m1Jb/Ck0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uu9J8K0YhCuh8Yktp5o1LKPFEk9KGFwSJRE7D/aLB7ZK1HL+aFZAUznZyXywvltcj ApEqMdQq+70103AueDnaAj2dp0DVkn0y4efnewIhR+lX5j8MptTMbZVWcKNs/kQuKB xivgGaFMZqTzgcceva/6UJiYQqgwz7bChyXsNeTKvL/OvfByTHPMZRztddNo7PfXgd /Tc5S9cwYi7Ba0/8r0hCtSSOB9JRVnazzBdvrlgQ9j5LIFEgFfzE9AJ3vAFa3pxmLL 7BbWkazbaCyIO/9+eWjn9TNoM+bFKWHsuAA+m+k7EsNNtCqOQT84bYwKWGdrlmoKy2 mvSvC2ZMIsj5w== From: Aaron Ma To: kernel-team@lists.ubuntu.com Subject: [K][PATCH 4/4] wifi: mt76: mt7921: fix use after free in mt7921_acpi_read() Date: Mon, 21 Nov 2022 13:55:37 +0800 Message-Id: <20221121055537.3796-5-aaron.ma@canonical.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121055537.3796-1-aaron.ma@canonical.com> References: <20221121055537.3796-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 */