diff options
author | Amitoj Kaur Chawla <[email protected]> | 2016-03-12 15:01:04 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2016-03-28 07:30:36 -0700 |
commit | 514dd88df707a1094e937c20d5a0b1ec619e1f96 (patch) | |
tree | 48e2aae5fcc280530df1137ca9a99ace19a29cde | |
parent | afb105549d4879018e45bbf77e76034237d8fc20 (diff) |
staging: slicoss: Add error check for pci_map_single
Currently, DMA mapping failure is not detected, causing the hardware
to attempt a DMA from an invalid address.
This patch adds the corresponding error check for pci_map_single i.e.
pci_dma_mapping_error.
Problem found using the following Coccinelle semantic patch:
// <smpl>
@@
expression e1;
identifier x;
@@
x=
(
*dma_map_single(...)
|
*dma_map_page(...)
)
... when != dma_mapping_error(e1,x)
@@
expression e1;
identifier x;
@@
x =
(
*pci_map_single(...)
|
*pci_map_page(...)
)
... when != pci_dma_mapping_error(e1,x)
// </smpl>
Signed-off-by: Amitoj Kaur Chawla <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r-- | drivers/staging/slicoss/slicoss.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 6d50fc4fd02e..fa61e8e9964b 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1855,6 +1855,11 @@ static void slic_xmit_build_request(struct adapter *adapter, ihcmd->u.slic_buffers.totlen = skb->len; phys_addr = pci_map_single(adapter->pcidev, skb->data, skb->len, PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(adapter->pcidev, phys_addr)) { + kfree_skb(skb); + dev_err(&adapter->pcidev->dev, "DMA mapping error\n"); + return; + } ihcmd->u.slic_buffers.bufs[0].paddrl = SLIC_GET_ADDR_LOW(phys_addr); ihcmd->u.slic_buffers.bufs[0].paddrh = SLIC_GET_ADDR_HIGH(phys_addr); ihcmd->u.slic_buffers.bufs[0].length = skb->len; |