Staging: vt6655: Add check dma_mapping_error
authorHaneen Mohammed <hamohammed.sa@gmail.com>
Thu, 11 Feb 2016 18:34:40 +0000 (21:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Feb 2016 04:00:30 +0000 (20:00 -0800)
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>
drivers/staging/vt6655/device_main.c

index ad0fb84e5096f43c6261e58ed237733f19b1d0d6..8a1ed62e2f577102c13e40f79cdb21e2645ec919 100644 (file)
@@ -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 */