From patchwork Thu May 25 00:11:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9747209 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4EA6360246 for ; Thu, 25 May 2017 00:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4021926E47 for ; Thu, 25 May 2017 00:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3434727031; Thu, 25 May 2017 00:11:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEFCE26E54 for ; Thu, 25 May 2017 00:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164723AbdEYALn (ORCPT ); Wed, 24 May 2017 20:11:43 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:34389 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164693AbdEYALi (ORCPT ); Wed, 24 May 2017 20:11:38 -0400 Received: by mail-pf0-f178.google.com with SMTP id 9so150117018pfj.1 for ; Wed, 24 May 2017 17:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OP7eLaya5XczKWti6VuYmeEVeCdEt9SWfNeVOftC4YQ=; b=Sg5YzqCyBfeKwI1QOaguKOZuKeqTURcHSzXAspRunak9Bpka7s4FrVxLWvdv9peWLj ImLUTi7SvHTH4+PshAY+/uWkIUCABESCqQwm05S9dA7eaf68YuWedWviPel/oOZM6/G3 JjUMHMcO+4TXE0Rv9wCeRJIK8wTd5AQKULU4k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OP7eLaya5XczKWti6VuYmeEVeCdEt9SWfNeVOftC4YQ=; b=iqzvTly3DxO+WDKDxrh248+iXUUmf2euvBFK03wMpl0VMx6wymQCquFZvwXIO7oxDB X9elnbCDGdhk0ZoTjT1g0LUqXOWO4KCNLDqdJUuTdJTyrXBPv3z3iDWuyYh/yiVDH1Gr 9ZmUUyBQ7286q0UsKlrSBFteWgpxI05783LlWKHOuvQxQbZk9VgRphErzQB71rYWzQLI X+TUYSbFUDGCx07Y63RHxarvKP3Go8XZ9nHA9eSEaD50vLiw/w2lE46cvL1RqFcFcyRV FpHlGuVmkIklCbKDHotyiMHh2SNgMvwbqE0qpG2zmo9u7rNnUm3Szc90VXJhaej0fHd6 xDcQ== X-Gm-Message-State: AODbwcAE9uX4Ff94SBuFSX4DulZXDUQmEE0oymGqmuvWKGMAEAUyYqg3 LElCOiWH8LB0qVoz X-Received: by 10.99.97.68 with SMTP id v65mr42150044pgb.76.1495671097585; Wed, 24 May 2017 17:11:37 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id s23sm9823692pfg.81.2017.05.24.17.11.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 17:11:37 -0700 (PDT) From: Brian Norris To: Ganapathi Bhat , Nishant Sarmukadam Cc: , Dmitry Torokhov , Amitkumar Karwar , Kalle Valo , linux-wireless@vger.kernel.org, Brian Norris Subject: [PATCH 04/14] mwifiex: pcie: don't allow cmd buffer reuse after reset Date: Wed, 24 May 2017 17:11:09 -0700 Message-Id: <20170525001119.64791-4-briannorris@chromium.org> X-Mailer: git-send-email 2.13.0.219.gdb65acc882-goog In-Reply-To: <20170525001119.64791-1-briannorris@chromium.org> References: <20170525001119.64791-1-briannorris@chromium.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In rogue cases (due to other bugs) it's possible we try to process an old command response *after* resetting the device. This could trigger a double-free (or the SKB can get reallocated elsewhere...causing other memory corruptions) in mwifiex_pcie_process_cmd_complete(). For safety (and symmetry) let's always NULL out the command buffer as we free it up. We're already doing this for the command response buffer. Signed-off-by: Brian Norris --- drivers/net/wireless/marvell/mwifiex/pcie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index ea75315bf19d..3d5c29d79609 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -1060,12 +1060,14 @@ static int mwifiex_pcie_delete_cmdrsp_buf(struct mwifiex_adapter *adapter) mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, PCI_DMA_FROMDEVICE); dev_kfree_skb_any(card->cmdrsp_buf); + card->cmdrsp_buf = NULL; } if (card && card->cmd_buf) { mwifiex_unmap_pci_memory(adapter, card->cmd_buf, PCI_DMA_TODEVICE); dev_kfree_skb_any(card->cmd_buf); + card->cmd_buf = NULL; } return 0; } @@ -2946,7 +2948,6 @@ static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter) mwifiex_pcie_delete_evtbd_ring(adapter); mwifiex_pcie_delete_rxbd_ring(adapter); mwifiex_pcie_delete_txbd_ring(adapter); - card->cmdrsp_buf = NULL; } /*