From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6517446BF1; Thu, 30 Jul 2026 16:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785427785; cv=none; b=fpDk8A3i0GzqhhnuTGeEc/kprPxuNWowYrdrnuxTGSEeD8WOM8kN+5xGxd1WbTEAm8tkKkCoScJb7L1zPZhSjglahi3TWhz/lNdBvZxxCRy7CPewoLLenqttSPTy0rlRYLgsMT9yEVpWtO/j2FKtc0IZq83fWn/7ulES9iE2pT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785427785; c=relaxed/simple; bh=zC39GT5+lUzFZK1dDfJLZ8u6Jr3h7MXZtnBrji/QlC0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V1zXYUapFEgjHAJeIzACSAaqXMhljIgt3/CBCWLLnhQ3nib6dYc9rx1rsTFWKaVF/3nhSJ15hQiiSrqIK43ntK+D+zGcanVntLWA3wlVcLJB3fz2CuW70zlxMJWE8Ir4SFtJRnLQgWf9MRWuLaS4EYH5l3QIWZiVDEbjgX56tqk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nyu4Rwt6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nyu4Rwt6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2908F1F00A3D; Thu, 30 Jul 2026 16:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785427783; bh=qeSs6Jk46i8lA+wkS5dKmSm7z+jmgE9d2/CtZZecu80=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nyu4Rwt6EcbIgc2EilkPVlHTY13GHkAAMfJ/na83VTEdEd7e+HVgUaZ43jT9osQPc 7qSXX/rNBTu9fJpvODehUIwaiKUizjdTaUXKd0cU+N4abWMQOsIPw/6OnKuSDfaIqi 9zHfR7OZ2eaadN7VOWqOade9JQbV6cOvHelSWY/0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fan Wu , Arend van Spriel , Johannes Berg Subject: [PATCH 6.6 275/484] wifi: brcmfmac: make release_scratchbuffers idempotent Date: Thu, 30 Jul 2026 16:12:52 +0200 Message-ID: <20260730141429.467563522@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141423.392222816@linuxfoundation.org> References: <20260730141423.392222816@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fan Wu commit 538c51e9d124cf656f2dd0c0394a8545efc7102d upstream. brcmf_pcie_release_scratchbuffers() frees the shared.scratch and shared.ringupd DMA buffers with dma_free_coherent() but does not clear the pointers afterwards, unlike the sibling release_ringbuffers() which NULLs commonrings/flowrings/idxbuf on release. Both the bus_reset .reset callback (brcmf_pcie_reset) and brcmf_pcie_remove() call release_scratchbuffers. When reset teardown has run before removal, remove's own teardown would call dma_free_coherent() a second time on the already-freed DMA allocation. NULL the pointers after free, matching release_ringbuffers(), so a later release observes that the allocation has already been released. This patch makes repeated sequential release safe; the reset-work lifetime is handled separately by the following patch. This issue was found by an in-house static analysis tool. Fixes: 4684997d9eea ("brcmfmac: reset PCIe bus on a firmware crash") Cc: stable@vger.kernel.org Signed-off-by: Fan Wu Assisted-by: Codex:gpt-5.6 Acked-by: Arend van Spriel Link: https://patch.msgid.link/20260718024353.3147201-2-fanwu01@zju.edu.cn Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1381,16 +1381,20 @@ fail: static void brcmf_pcie_release_scratchbuffers(struct brcmf_pciedev_info *devinfo) { - if (devinfo->shared.scratch) + if (devinfo->shared.scratch) { dma_free_coherent(&devinfo->pdev->dev, BRCMF_DMA_D2H_SCRATCH_BUF_LEN, devinfo->shared.scratch, devinfo->shared.scratch_dmahandle); - if (devinfo->shared.ringupd) + devinfo->shared.scratch = NULL; + } + if (devinfo->shared.ringupd) { dma_free_coherent(&devinfo->pdev->dev, BRCMF_DMA_D2H_RINGUPD_BUF_LEN, devinfo->shared.ringupd, devinfo->shared.ringupd_dmahandle); + devinfo->shared.ringupd = NULL; + } } static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo)