diff options
author | françois romieu <romieu@fr.zoreil.com> | 2012-12-01 08:08:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-01 20:39:17 -0500 |
commit | 892a925e42adb8192a3c832ad29cbc780fc466f6 (patch) | |
tree | c89458159f626aa6b722d04331b1bb43c258d150 | |
parent | 64022d0b4e93ea432e95db55a72b8a1c5775f3c0 (diff) |
8139cp: fix coherent mapping leak in error path.
cp_open
[...]
rc = cp_alloc_rings(cp);
if (rc)
return rc;
cp_alloc_rings
[...]
mem = dma_alloc_coherent(&cp->pdev->dev, CP_RING_BYTES,
&cp->ring_dma, GFP_KERNEL);
- cp_alloc_rings never frees the coherent mapping it allocates
- neither do cp_open when cp_alloc_rings fails
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/realtek/8139cp.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index b01f83a044c4..609125a249d9 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c | |||
@@ -1060,17 +1060,22 @@ static int cp_init_rings (struct cp_private *cp) | |||
1060 | 1060 | ||
1061 | static int cp_alloc_rings (struct cp_private *cp) | 1061 | static int cp_alloc_rings (struct cp_private *cp) |
1062 | { | 1062 | { |
1063 | struct device *d = &cp->pdev->dev; | ||
1063 | void *mem; | 1064 | void *mem; |
1065 | int rc; | ||
1064 | 1066 | ||
1065 | mem = dma_alloc_coherent(&cp->pdev->dev, CP_RING_BYTES, | 1067 | mem = dma_alloc_coherent(d, CP_RING_BYTES, &cp->ring_dma, GFP_KERNEL); |
1066 | &cp->ring_dma, GFP_KERNEL); | ||
1067 | if (!mem) | 1068 | if (!mem) |
1068 | return -ENOMEM; | 1069 | return -ENOMEM; |
1069 | 1070 | ||
1070 | cp->rx_ring = mem; | 1071 | cp->rx_ring = mem; |
1071 | cp->tx_ring = &cp->rx_ring[CP_RX_RING_SIZE]; | 1072 | cp->tx_ring = &cp->rx_ring[CP_RX_RING_SIZE]; |
1072 | 1073 | ||
1073 | return cp_init_rings(cp); | 1074 | rc = cp_init_rings(cp); |
1075 | if (rc < 0) | ||
1076 | dma_free_coherent(d, CP_RING_BYTES, cp->rx_ring, cp->ring_dma); | ||
1077 | |||
1078 | return rc; | ||
1074 | } | 1079 | } |
1075 | 1080 | ||
1076 | static void cp_clean_rings (struct cp_private *cp) | 1081 | static void cp_clean_rings (struct cp_private *cp) |