From patchwork Sun May 7 19:03:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 9715457 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 B3808602BD for ; Sun, 7 May 2017 21:51:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4F2C23B24 for ; Sun, 7 May 2017 21:51:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9804326C9B; Sun, 7 May 2017 21:51:20 +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, FREEMAIL_FROM, 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 083A8265B9 for ; Sun, 7 May 2017 21:51:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755661AbdEGVvR (ORCPT ); Sun, 7 May 2017 17:51:17 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35482 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752982AbdEGVvQ (ORCPT ); Sun, 7 May 2017 17:51:16 -0400 Received: by mail-wm0-f68.google.com with SMTP id v4so6808139wmb.2; Sun, 07 May 2017 14:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=bT4GVRDq1AbvkG1X2sK64A85t0X38tX455QfwCPLjQw=; b=qaXSfIhYw1mBLCX5mFlKbOJ1VIWAt41eCeNMeqS2e9mfWewsVJTn1n3HHTSvq/fnKv pngDzTSnA4998QkCnRp0xpYEJn18t1UrbjpRmftRALk+MkflyVGC4IVZ5nj4YM7yvGWx G4PjZA1jQrYJiZ3q9PL+2okgpUJendGJXaJMy5O9p37zLvCsD7b+l5tWuWRsCruqoY+X E2saJjaZuEiCdF9vQ1bqCt/rJY+7x/0pR+OlXipb6oInnBYk4lz6nkbWSfzxLfOaesd4 H5gMAJVi4dbqhK6o9S0CDeMcFFZq+6fpJ3YxFU0HUXFxUL2ACT5DEsa9L0TrYXUK6iTI wFrw== 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; bh=bT4GVRDq1AbvkG1X2sK64A85t0X38tX455QfwCPLjQw=; b=h3E7wpx9trdw+0113UuBmmaDvgcHcQaGVtaHmHfSULrczQjpefqmRa3H5xec5stA3R kipQ7I0SPQVkUX4vlqrf//I4VYVXwY/1KdXvhLhlb9AAU5plJV3O/TB5txNMibKRxo/S FU7IXVPeiIXDViHdz892oyz1nZcv1jp2/6osxmVvC96dvpvSgPCvl9e2aYwdsnQy1rqn 8e8R74iab6z021TbJRyjTT3fI1TFWXmONA6y4fwp1/DNEXINnujtlOh6l+eDUIXrQpzN EZ0AFnydKjMuuYRcG4bKEZNWNEtSieDARDnt9f55JjsTONACvGbd+eEZ5+miaRjUGFfo u+uw== X-Gm-Message-State: AODbwcDQZhTmCMQHaZNSbAHK3mYMWrVqOWuPj4nB0b2AoSq+oOCc+eKh Pk9LEol4dDvSzQeH73QmIw== X-Received: by 10.28.209.141 with SMTP id i135mr3074490wmg.123.1494183861881; Sun, 07 May 2017 12:04:21 -0700 (PDT) Received: from localhost.localdomain (92.40.248.139.threembb.co.uk. [92.40.248.139]) by smtp.gmail.com with ESMTPSA id t85sm10711291wmt.23.2017.05.07.12.04.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 May 2017 12:04:21 -0700 (PDT) From: Malcolm Priestley To: gregkh@linuxfoundation.org Cc: linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Malcolm Priestley , stable@vger.kernel.org Subject: [PATCH 1/3] staging: rtl8192e rtl92e_fill_tx_desc fix write to mapped out memory. Date: Sun, 7 May 2017 20:03:51 +0100 Message-Id: <20170507190353.3195-1-tvboxspy@gmail.com> X-Mailer: git-send-email 2.11.0 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 The driver attempts to alter memory that is mapped to PCI device. This is because tx_fwinfo_8190pci points to skb->data. Move the pci_map_single to when completed buffer is ready to be mapped with psdec is empty to drop on mapping error. Fixes slow operation and tx queue fails. Signed-off-by: Malcolm Priestley Cc: --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 4723a0bd5067..a23628f390c9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -1182,8 +1182,7 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, struct cb_desc *cb_desc, struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, - PCI_DMA_TODEVICE); + dma_addr_t mapping; struct tx_fwinfo_8190pci *pTxFwInfo; pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; @@ -1194,8 +1193,6 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT, pTxFwInfo->TxRate, cb_desc); - if (pci_dma_mapping_error(priv->pdev, mapping)) - netdev_err(dev, "%s(): DMA Mapping error\n", __func__); if (cb_desc->bAMPDUEnable) { pTxFwInfo->AllowAggregation = 1; pTxFwInfo->RxMF = cb_desc->ampdu_factor; @@ -1230,6 +1227,14 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, } memset((u8 *)pdesc, 0, 12); + + mapping = pci_map_single(priv->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(priv->pdev, mapping)) { + netdev_err(dev, "%s(): DMA Mapping error\n", __func__); + return; + } + pdesc->LINIP = 0; pdesc->CmdInit = 1; pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8;