diff options
author | Ali Ayoub <ali@dev.mellanox.co.il> | 2011-01-10 20:42:06 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2011-01-10 20:42:06 -0500 |
commit | 030b4b3309e29c6c857d8521c3076743663c259e (patch) | |
tree | 07fb6c45846564c6c356f102216f5311c05ccad9 /drivers/net/mlx4/alloc.c | |
parent | 3afa9f19e5bd16abed998b7bf1b178206403286f (diff) |
mlx4_core: Avoid vunmap() of invalid pointer if allocation fails
Signed-off-by: Ali Ayoub <ali@mellanox.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/net/mlx4/alloc.c')
-rw-r--r-- | drivers/net/mlx4/alloc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c index 8f4bf1f07c11..3a4277f6fac4 100644 --- a/drivers/net/mlx4/alloc.c +++ b/drivers/net/mlx4/alloc.c | |||
@@ -178,6 +178,7 @@ int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | |||
178 | } else { | 178 | } else { |
179 | int i; | 179 | int i; |
180 | 180 | ||
181 | buf->direct.buf = NULL; | ||
181 | buf->nbufs = (size + PAGE_SIZE - 1) / PAGE_SIZE; | 182 | buf->nbufs = (size + PAGE_SIZE - 1) / PAGE_SIZE; |
182 | buf->npages = buf->nbufs; | 183 | buf->npages = buf->nbufs; |
183 | buf->page_shift = PAGE_SHIFT; | 184 | buf->page_shift = PAGE_SHIFT; |
@@ -229,7 +230,7 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf) | |||
229 | dma_free_coherent(&dev->pdev->dev, size, buf->direct.buf, | 230 | dma_free_coherent(&dev->pdev->dev, size, buf->direct.buf, |
230 | buf->direct.map); | 231 | buf->direct.map); |
231 | else { | 232 | else { |
232 | if (BITS_PER_LONG == 64) | 233 | if (BITS_PER_LONG == 64 && buf->direct.buf) |
233 | vunmap(buf->direct.buf); | 234 | vunmap(buf->direct.buf); |
234 | 235 | ||
235 | for (i = 0; i < buf->nbufs; ++i) | 236 | for (i = 0; i < buf->nbufs; ++i) |