diff options
author | Leon Romanovsky <leonro@mellanox.com> | 2016-12-29 18:37:11 +0200 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2017-11-02 10:45:58 +0100 |
commit | 50602d3e499b2419b7ff0eda022525625f90e53c (patch) | |
tree | 3eefe97ce6650715d385dadbf051f72637808d1e | |
parent | c1327b455fda6390d2b1b199ce35b20d2bd3dea8 (diff) | |
download | linux-stable-50602d3e499b2419b7ff0eda022525625f90e53c.tar.gz |
net/mlx4: Remove BUG_ON from ICM allocation routine
commit c1d5f8ff80ea84768f5fae1ca9d1abfbb5e6bbaa upstream.
This patch removes BUG_ON() macro from mlx4_alloc_icm_coherent()
by checking DMA address alignment in advance and performing proper
folding in case of error.
Fixes: 5b0bf5e25efe ("mlx4_core: Support ICM tables in coherent memory")
Reported-by: Ozgur Karatas <okaratas@member.fsf.org>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/icm.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c index 31d02649be41..d22482b49744 100644 --- a/drivers/net/ethernet/mellanox/mlx4/icm.c +++ b/drivers/net/ethernet/mellanox/mlx4/icm.c @@ -113,8 +113,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem, if (!buf) return -ENOMEM; + if (offset_in_page(buf)) { + dma_free_coherent(dev, PAGE_SIZE << order, + buf, sg_dma_address(mem)); + return -ENOMEM; + } + sg_set_buf(mem, buf, PAGE_SIZE << order); - BUG_ON(mem->offset); sg_dma_len(mem) = PAGE_SIZE << order; return 0; } |