diff options
author | Greg Rose <gregory.v.rose@intel.com> | 2012-09-20 20:21:39 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2012-10-30 02:48:58 -0400 |
commit | 91ffb8e0dc662868addeff9fd013145c49a43c4a (patch) | |
tree | fee430bdc1420e92340a48b6aab345eb37aba5eb /drivers/net/ethernet/intel/igbvf | |
parent | f9d08f165b8a5a4af6f827318e692b57bc683825 (diff) |
igbvf: Check for error on dma_map_single call
Ignoring the return value from a call to the kernel dma_map API functions
can cause data corruption and system instability. Check the return value
and take appropriate action.
Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Tested-by: Sibai Li <sibai.li@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/igbvf')
-rw-r--r-- | drivers/net/ethernet/intel/igbvf/netdev.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index 0ac11f527a84..4051ec404613 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c | |||
@@ -184,6 +184,13 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring, | |||
184 | buffer_info->page_offset, | 184 | buffer_info->page_offset, |
185 | PAGE_SIZE / 2, | 185 | PAGE_SIZE / 2, |
186 | DMA_FROM_DEVICE); | 186 | DMA_FROM_DEVICE); |
187 | if (dma_mapping_error(&pdev->dev, | ||
188 | buffer_info->page_dma)) { | ||
189 | __free_page(buffer_info->page); | ||
190 | buffer_info->page = NULL; | ||
191 | dev_err(&pdev->dev, "RX DMA map failed\n"); | ||
192 | break; | ||
193 | } | ||
187 | } | 194 | } |
188 | 195 | ||
189 | if (!buffer_info->skb) { | 196 | if (!buffer_info->skb) { |
@@ -197,6 +204,12 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring, | |||
197 | buffer_info->dma = dma_map_single(&pdev->dev, skb->data, | 204 | buffer_info->dma = dma_map_single(&pdev->dev, skb->data, |
198 | bufsz, | 205 | bufsz, |
199 | DMA_FROM_DEVICE); | 206 | DMA_FROM_DEVICE); |
207 | if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { | ||
208 | dev_kfree_skb(buffer_info->skb); | ||
209 | buffer_info->skb = NULL; | ||
210 | dev_err(&pdev->dev, "RX DMA map failed\n"); | ||
211 | goto no_buffers; | ||
212 | } | ||
200 | } | 213 | } |
201 | /* Refresh the desc even if buffer_addrs didn't change because | 214 | /* Refresh the desc even if buffer_addrs didn't change because |
202 | * each write-back erases this info. */ | 215 | * each write-back erases this info. */ |