diff options
author | andrea merello <andrea.merello@gmail.com> | 2014-02-22 20:57:23 +0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-02-28 23:08:27 +0400 |
commit | ec1da08dd721f53b97e792c749d236907c764932 (patch) | |
tree | 82ee8cc494173ae21214d09ca28f0c880c84e2c8 /drivers | |
parent | 0269da281599fba2bc8bed30953d5a3ff3b083e5 (diff) | |
download | linux-ec1da08dd721f53b97e792c749d236907c764932.tar.xz |
rtl818x: check for pci_map_single() success when initializing RX ring
During initialization a number of RX skbs are allocated and mapped
for DMA.
Currently if pci_map_single() fails, it will result in passing to the
HW a wrong DMA address (to write to!).
This patch adds check for this condition and eventually causes the
driver not to initialize, avoiding at least dangerous DMAs.
Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/rtl818x/rtl8180/dev.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index bf59ff988952..0102da2f145a 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -483,6 +483,13 @@ static int rtl8180_init_rx_ring(struct ieee80211_hw *dev) mapping = (dma_addr_t *)skb->cb; *mapping = pci_map_single(priv->pdev, skb_tail_pointer(skb), MAX_RX_SIZE, PCI_DMA_FROMDEVICE); + + if (pci_dma_mapping_error(priv->pdev, *mapping)) { + kfree_skb(skb); + wiphy_err(dev->wiphy, "Cannot map DMA for RX skb\n"); + return -ENOMEM; + } + entry->rx_buf = cpu_to_le32(*mapping); entry->flags = cpu_to_le32(RTL818X_RX_DESC_FLAG_OWN | MAX_RX_SIZE); |