Skip to contentSkip to conversation

Staging: vt6655: Add check dma_mapping_error

PATCH In review Haneen Mohammed 2 participants 2 messages Feb 11, 2016 – Feb 12, 2016 Staging

lore
Share & tools
lore
#0 lore raw

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.

---
 drivers/staging/vt6655/device_main.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/staging/vt6655/device_main.c +5 -0
index ad0fb84..8a1ed62 100644
@@ -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
maintainer
#1 lore raw
Quoted 5 lines · Haneen Mohammed

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.

Nice catch.