aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/mlx4
diff options
context:
space:
mode:
authorAli Ayoub <ali@dev.mellanox.co.il>2011-01-10 17:42:06 -0800
committerRoland Dreier <rolandd@cisco.com>2011-01-10 17:42:06 -0800
commit030b4b3309e29c6c857d8521c3076743663c259e (patch)
tree07fb6c45846564c6c356f102216f5311c05ccad9 /drivers/net/mlx4
parent3afa9f19e5bd16abed998b7bf1b178206403286f (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')
-rw-r--r--drivers/net/mlx4/alloc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c
index 8f4bf1f07c1..3a4277f6fac 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,
} else {
int i;
+ buf->direct.buf = NULL;
buf->nbufs = (size + PAGE_SIZE - 1) / PAGE_SIZE;
buf->npages = buf->nbufs;
buf->page_shift = PAGE_SHIFT;
@@ -229,7 +230,7 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf)
dma_free_coherent(&dev->pdev->dev, size, buf->direct.buf,
buf->direct.map);
else {
- if (BITS_PER_LONG == 64)
+ if (BITS_PER_LONG == 64 && buf->direct.buf)
vunmap(buf->direct.buf);
for (i = 0; i < buf->nbufs; ++i)