mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
27f31cf9f7
commit
2fbf6d6166
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue