Staging: vt6655: Add check dma_mapping_error
PATCH 1/1 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 <[email protected]>
--- drivers/staging/vt6655/device_main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/staging/vt6655/device_main.c +5 -0
@@ -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 */
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 5 lines · Haneen Mohammed
This patch checks for
dma_mapping_error()after usingdma_map_single. If the dma map fails we release skb buff allocated bydev_alloc_skb()to avoid possible causes of resource leak.Signed-off-by Haneen Mohammed <[email protected]>
Nice catch.