From patchwork Wed Oct 19 08:26:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp211946wrs; Wed, 19 Oct 2022 02:06:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4RG/g//IsMvM+6aMy6q9roKDv4Z3fq4NrmbuaLpbcetgrBjPmJgbPhqHv/XpI8lJoayEkA X-Received: by 2002:a17:906:b08d:b0:782:d526:3e36 with SMTP id x13-20020a170906b08d00b00782d5263e36mr5886087ejy.358.1666170378884; Wed, 19 Oct 2022 02:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170378; cv=none; d=google.com; s=arc-20160816; b=JeayAz+GklvRHeJ4XFjsjaBFPmLeTkg7aPRUSRJ6PWiqnAyIqLSOZsGjGEAQ5/S6zt 6ZC63zjXJ6UbfVTAzQEAgZJHZYpkSIAWaJrLKfoCJfSmiOBIEVcM1FEY2p4qkVWiq6GY xwOKOGlcVF5Ft9NIfjMfNjqSZ+7wyav2iu00/2EoR3rrkUA/r/rP2qyprxfV8+lB007h nqnIcp2t0VxcsOK8diG3uO6qRWNa44a+vV5I3C3kjQpx1yJ/mI8iHnNiVrkssrh9o9W8 SbI5fQ0EDi3MFQWYRfcL16rgPq95nq/jYcBmxJBeC8awiw114SihLBr5pD7kwxcYkFlN KCcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lswE+F6V1jSOfcAdXoKPWxPJCqcGz8cksMXS6oNULv8=; b=THNzn1SjP0wRBOAf2+69G38FdxFVy6Nl04V2Dy6uxf2Xfhlj993EspKCq/Sbo3itkZ HtfcSzeUGjGsuiOBftRGX6futg2yaZMetlEMTRQMSzcetnCz9ZtfYpt0HC2NZ+ilbu2T g/NnmsEMnjqqLPsUfqXDxxplZ3S8HAUtphbJ3rUUywh7dYo0VrcfZhTFv8O21mloJPZW xIvtnSvMT3G0rM61SD+fULlpITZR5fP/PbuKkxDUX6SMvkMRxiu8alkmUdt4X37KbCfR uuER2B5TqQsBsJyhOuH5b4fMVGN/z3wRAttIPRgOjrfjUwsTQkbvtaEjDpEoumlFab0b nSjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f86j4q0i; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg3-20020a1709072cc300b007839bfdaa33si11071820ejc.358.2022.10.19.02.05.45; Wed, 19 Oct 2022 02:06:18 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f86j4q0i; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231687AbiJSI4W (ORCPT + 99 others); Wed, 19 Oct 2022 04:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232221AbiJSIzF (ORCPT ); Wed, 19 Oct 2022 04:55:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D17C9AFB3; Wed, 19 Oct 2022 01:52:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9040C6181D; Wed, 19 Oct 2022 08:50:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4324C433D6; Wed, 19 Oct 2022 08:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169448; bh=8V/2WBaxDidT9ubYw7k2req5w3xsG1WRMgg2TbhCdpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f86j4q0izFUzIqYktpMc9gBd4kRY72gnov2TxABdZBSfwuNC75SLBKhFI/ZhpMwY4 SjkE0BpQedmLiaw5EeamVKbTiZh13O7QLyAOh28XWHWNEPwGcaoa5HjU0EJM0VtueA mC0g1vCC/ECkL4yns9wI7i/0anDg0EDS/oS8xoT0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Felix Fietkau , Sasha Levin Subject: [PATCH 6.0 281/862] wifi: mt76: mt7921: fix use after free in mt7921_acpi_read() Date: Wed, 19 Oct 2022 10:26:08 +0200 Message-Id: <20221019083302.440733021@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1747106271435285456?= X-GMAIL-MSGID: =?utf-8?q?1747106271435285456?= From: Dan Carpenter [ Upstream commit e7de4b4979bd8d313ec837931dde936653ca82ea ] 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 Signed-off-by: Sasha Levin --- 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 be4f07ad3af9..47e034a9b003 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 */