diff options
author | Haneen Mohammed <hamohammed.sa@gmail.com> | 2016-02-11 21:34:40 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-11 20:00:30 -0800 |
commit | 2fbf6d61664ba04d4c7872cbb46720e49264cf3a (patch) | |
tree | e61fc6db3455e664f2b9480dd3750cb62b3fedc3 | |
parent | 27f31cf9f7235cb3aa10860bf4fde5df6893bf52 (diff) |
Staging: vt6655: Add check dma_mapping_error
This patch checks for dma_mapping_error() after using dma_map_single.
If the dma map fails we release skb buff allocated by dev_alloc_skb() to
avoid possible causes of resource leak.
Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/vt6655/device_main.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index ad0fb84e5096..8a1ed62e2f57 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -742,6 +742,11 @@ static bool device_alloc_rx_buf(struct vnt_private *priv, dma_map_single(&priv->pcid->dev, skb_put(rd_info->skb, skb_tailroom(rd_info->skb)), priv->rx_buf_sz, DMA_FROM_DEVICE); + if (dma_mapping_error(&priv->pcid->dev, rd_info->skb_dma)) { + dev_kfree_skb(rd_info->skb); + rd_info->skb = NULL; + return false; + } *((unsigned int *)&rd->rd0) = 0; /* FIX cast */ |