Skip to content

Commit 691fe56

Browse files
Malcolm Priestleygregkh
authored andcommitted
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>
1 parent 3fc4d70 commit 691fe56

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,7 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc,
11851185
struct cb_desc *cb_desc, struct sk_buff *skb)
11861186
{
11871187
struct r8192_priv *priv = rtllib_priv(dev);
1188-
dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len,
1189-
PCI_DMA_TODEVICE);
1188+
dma_addr_t mapping;
11901189
struct tx_fwinfo_8190pci *pTxFwInfo = NULL;
11911190

11921191
pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data;
@@ -1197,8 +1196,6 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc,
11971196
pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT,
11981197
pTxFwInfo->TxRate, cb_desc);
11991198

1200-
if (pci_dma_mapping_error(priv->pdev, mapping))
1201-
netdev_err(dev, "%s(): DMA Mapping error\n", __func__);
12021199
if (cb_desc->bAMPDUEnable) {
12031200
pTxFwInfo->AllowAggregation = 1;
12041201
pTxFwInfo->RxMF = cb_desc->ampdu_factor;
@@ -1233,6 +1230,14 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc,
12331230
}
12341231

12351232
memset((u8 *)pdesc, 0, 12);
1233+
1234+
mapping = pci_map_single(priv->pdev, skb->data, skb->len,
1235+
PCI_DMA_TODEVICE);
1236+
if (pci_dma_mapping_error(priv->pdev, mapping)) {
1237+
netdev_err(dev, "%s(): DMA Mapping error\n", __func__);
1238+
return;
1239+
}
1240+
12361241
pdesc->LINIP = 0;
12371242
pdesc->CmdInit = 1;
12381243
pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8;

0 commit comments

Comments
 (0)