From patchwork Tue Jul 25 01:13:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9860947 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 E5867603FA for ; Tue, 25 Jul 2017 01:15:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7EA82858E for ; Tue, 25 Jul 2017 01:15:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB2E32842E; Tue, 25 Jul 2017 01:15:01 +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 7DF54285D5 for ; Tue, 25 Jul 2017 01:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756842AbdGYBOl (ORCPT ); Mon, 24 Jul 2017 21:14:41 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:34255 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756703AbdGYBOO (ORCPT ); Mon, 24 Jul 2017 21:14:14 -0400 Received: by mail-pg0-f54.google.com with SMTP id 123so64046332pgj.1 for ; Mon, 24 Jul 2017 18:14:14 -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=6Nl1KLQe9VJ+yrx1eGNWsh/tjnVfYxw+/Tt7QFEsN1A=; b=SUqBg+nXdW6LUODCAGGxSibBlGBrwJ+PbvSy9tytH3YJiYFCBYcOWShNmG2y03jaik Iv1K2FJyQg71qSgnTexC+1vHczkwHR2JXnqtPpLZoF3bU0s5FMqMHbdGMCKpEWcxmJ26 y4wwvNdVezeH++fd/JrB6B330bENYY35mf4yk= 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=6Nl1KLQe9VJ+yrx1eGNWsh/tjnVfYxw+/Tt7QFEsN1A=; b=Hgyz11o2CGd6oLwqcSrBqatJzhvgYRt1Hk52IJKVjeYs2m/BUSRme0Xr4laKi5NsqR 64bQJETnyQzXRmxdzorthSfyaNAZa+6PLcOw4AqQGSOE0LnH4/Ir49hdmeAEGAbz6MRV 5VjJ4+V42YARrSVt6GpORvO3ZNI3sc7/XL4zu9w3QPtZo7I87qrG0U3ioEDxpy8HTzjB 2565cXzjnPgpWiOdoxgzbANzsIuY/WbTL59iXeZ7nG1AjIyb4291yxMDjuG3Y6TjY64D 3ORKPvu+b0FQsZvrifKJ3A7EB9R7hp2OeBqH008+V9aYEI/yhHyD2EujTHbftCzgkVqO TBxA== X-Gm-Message-State: AIVw112ixu255eqSWUrPXviK+tAE95243dBTUmMTk9OQw4/RvBP5QpcK 8TEIJzpi6CNKHYYO X-Received: by 10.99.149.6 with SMTP id p6mr13128021pgd.412.1500945253831; Mon, 24 Jul 2017 18:14:13 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.113.17]) by smtp.gmail.com with ESMTPSA id h123sm21497036pgc.36.2017.07.24.18.14.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Jul 2017 18:14:13 -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 v2 03/20] mwifiex: pcie: don't allow cmd buffer reuse after reset Date: Mon, 24 Jul 2017 18:13:19 -0700 Message-Id: <20170725011336.99993-4-briannorris@chromium.org> X-Mailer: git-send-email 2.14.0.rc0.284.gd933b75aa4-goog In-Reply-To: <20170725011336.99993-1-briannorris@chromium.org> References: <20170725011336.99993-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 --- v2: no change --- 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 b53ecf1eddda..5c07edd4e094 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -1030,12 +1030,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; } @@ -2921,7 +2923,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; } /*