diff options
author | Malcolm Priestley <tvboxspy@gmail.com> | 2017-05-11 13:57:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-25 09:44:45 -0400 |
commit | f4205502948b5825254e31d9c82d377beb85d100 (patch) | |
tree | 69d823b3ef6b47811f8dad11e579eac9c7a06a4f | |
parent | e6b8f5ade3059be9cf8ab5a290c312d463b54a39 (diff) |
staging: rtl8192e: rtl92e_fill_tx_desc fix write to mapped out memory.
commit baabd567f87be05330faa5140f72a91960e7405a upstream.
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 <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 8d6bca61e7aa..fa1440e15382 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | |||
@@ -1184,8 +1184,7 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, | |||
1184 | struct cb_desc *cb_desc, struct sk_buff *skb) | 1184 | struct cb_desc *cb_desc, struct sk_buff *skb) |
1185 | { | 1185 | { |
1186 | struct r8192_priv *priv = rtllib_priv(dev); | 1186 | struct r8192_priv *priv = rtllib_priv(dev); |
1187 | dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, | 1187 | dma_addr_t mapping; |
1188 | PCI_DMA_TODEVICE); | ||
1189 | struct tx_fwinfo_8190pci *pTxFwInfo; | 1188 | struct tx_fwinfo_8190pci *pTxFwInfo; |
1190 | 1189 | ||
1191 | pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; | 1190 | pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; |
@@ -1196,8 +1195,6 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, | |||
1196 | pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT, | 1195 | pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT, |
1197 | pTxFwInfo->TxRate, cb_desc); | 1196 | pTxFwInfo->TxRate, cb_desc); |
1198 | 1197 | ||
1199 | if (pci_dma_mapping_error(priv->pdev, mapping)) | ||
1200 | netdev_err(dev, "%s(): DMA Mapping error\n", __func__); | ||
1201 | if (cb_desc->bAMPDUEnable) { | 1198 | if (cb_desc->bAMPDUEnable) { |
1202 | pTxFwInfo->AllowAggregation = 1; | 1199 | pTxFwInfo->AllowAggregation = 1; |
1203 | pTxFwInfo->RxMF = cb_desc->ampdu_factor; | 1200 | pTxFwInfo->RxMF = cb_desc->ampdu_factor; |
@@ -1232,6 +1229,14 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, | |||
1232 | } | 1229 | } |
1233 | 1230 | ||
1234 | memset((u8 *)pdesc, 0, 12); | 1231 | memset((u8 *)pdesc, 0, 12); |
1232 | |||
1233 | mapping = pci_map_single(priv->pdev, skb->data, skb->len, | ||
1234 | PCI_DMA_TODEVICE); | ||
1235 | if (pci_dma_mapping_error(priv->pdev, mapping)) { | ||
1236 | netdev_err(dev, "%s(): DMA Mapping error\n", __func__); | ||
1237 | return; | ||
1238 | } | ||
1239 | |||
1235 | pdesc->LINIP = 0; | 1240 | pdesc->LINIP = 0; |
1236 | pdesc->CmdInit = 1; | 1241 | pdesc->CmdInit = 1; |
1237 | pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; | 1242 | pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; |