From patchwork Thu May 11 17:57:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 9722687 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 8C27760231 for ; Thu, 11 May 2017 17:58:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C39C286EB for ; Thu, 11 May 2017 17:58:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F81F286EE; Thu, 11 May 2017 17:58:03 +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 285B8286EB for ; Thu, 11 May 2017 17:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933482AbdEKR6C (ORCPT ); Thu, 11 May 2017 13:58:02 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34591 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932376AbdEKR6A (ORCPT ); Thu, 11 May 2017 13:58:00 -0400 Received: by mail-wm0-f66.google.com with SMTP id d127so8656619wmf.1; Thu, 11 May 2017 10:58:00 -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=fK4sbPB/weRfja5jxuXMfciVsLLrvisbipZn/Wn/5js=; b=aDHumrNAFcyS4yb70Bpldev9BQ+f6tH3MoUWqvJbu+82wtxyDTRxQyadmcQKVF8s5J XzBrbDqs+hXJZNGHn7zCxs48LEUh2SpbrePxgaqY7+rs0E5GenNhs8YVNNz83zXfFA4B QYKoohcFEKMbInQliVCgP23mBVT32o6MQlWd6ZsLLiFYdcNBrrLlMGmpGvjU5A5i1b+1 9+WH2VFP0O35ynCB/86ZGmja7GCv+g0P5nEc/BI6NPx3PDGtsD9duaoqqVBW3j+k8kbV Z+AUtlkVUCYlqZhBlpyFSqy3RMfcejh0CbM4ImwQg50QdBVqYYTaLZV8AgptxZsEaIR8 5Svw== 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=fK4sbPB/weRfja5jxuXMfciVsLLrvisbipZn/Wn/5js=; b=MmguP6E4AjSmYIiXmLuR+8h6hM9bZjWTvVySd12R+G8MaPQIon01VcEOZQGXG0Z5dX jZXiTJrf1d/j+uxPijl/opIZN+5Zh1uxrasg1rAw7eH8VAbDuKb2KurRrML+f2cPbQgq 5EPCvdpF+iZ3AFydjYTZakQT4povpWXeUS0wHKjZkX4fCS1pXivqQisHbNECF7W5cgtb nP2Q4yCeo/lMuXbZiknbQLCZDwJvZirazJvOPRzeWhphCcWx9N3cUNVfhWw1iFgspzC3 Xw3fiEBHyMXs822087EUXCC7Vifp6C6bFUC4nu1QSAQFtW2aYjuP4griUOPLNCfQI5pS orxQ== X-Gm-Message-State: AODbwcDwcvOBnz0sZoRme57ndv4naX5Pyr9oWGTVurQMZlFp9ongcEdQ s5McTlxZth0/WQ== X-Received: by 10.28.223.195 with SMTP id w186mr37431wmg.3.1494525479474; Thu, 11 May 2017 10:57:59 -0700 (PDT) Received: from localhost.localdomain (92.40.248.21.threembb.co.uk. [92.40.248.21]) by smtp.gmail.com with ESMTPSA id u4sm1271084wmu.0.2017.05.11.10.57.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 10:57:58 -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 v2 1/4] staging: rtl8192e: rtl92e_fill_tx_desc fix write to mapped out memory. Date: Thu, 11 May 2017 18:57:43 +0100 Message-Id: <20170511175746.12378-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. Signed-off-by: Malcolm Priestley Cc: --- v2 - Fix typo in subject header. 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;