mirror of https://gitee.com/openkylin/linux.git
ixgbevf: 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: Phil Schmitt <phillip.j.schmitt@intel.com> Tested-by: Sibai Li <sibai.li@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
parent
f44777024c
commit
6132ee8a3f
|
@ -359,6 +359,12 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_adapter *adapter,
|
||||||
bi->dma = dma_map_single(&pdev->dev, skb->data,
|
bi->dma = dma_map_single(&pdev->dev, skb->data,
|
||||||
rx_ring->rx_buf_len,
|
rx_ring->rx_buf_len,
|
||||||
DMA_FROM_DEVICE);
|
DMA_FROM_DEVICE);
|
||||||
|
if (dma_mapping_error(&pdev->dev, bi->dma)) {
|
||||||
|
dev_kfree_skb(skb);
|
||||||
|
bi->skb = NULL;
|
||||||
|
dev_err(&pdev->dev, "RX DMA map failed\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rx_desc->read.pkt_addr = cpu_to_le64(bi->dma);
|
rx_desc->read.pkt_addr = cpu_to_le64(bi->dma);
|
||||||
|
|
||||||
|
@ -2817,10 +2823,10 @@ static int ixgbevf_tx_map(struct ixgbevf_ring *tx_ring,
|
||||||
tx_buffer_info->dma =
|
tx_buffer_info->dma =
|
||||||
skb_frag_dma_map(tx_ring->dev, frag,
|
skb_frag_dma_map(tx_ring->dev, frag,
|
||||||
offset, size, DMA_TO_DEVICE);
|
offset, size, DMA_TO_DEVICE);
|
||||||
tx_buffer_info->mapped_as_page = true;
|
|
||||||
if (dma_mapping_error(tx_ring->dev,
|
if (dma_mapping_error(tx_ring->dev,
|
||||||
tx_buffer_info->dma))
|
tx_buffer_info->dma))
|
||||||
goto dma_error;
|
goto dma_error;
|
||||||
|
tx_buffer_info->mapped_as_page = true;
|
||||||
tx_buffer_info->next_to_watch = i;
|
tx_buffer_info->next_to_watch = i;
|
||||||
|
|
||||||
len -= size;
|
len -= size;
|
||||||
|
|
Loading…
Reference in New Issue