Skip to content

Commit c1d5f8f

Browse files
Leon Romanovskydavem330
authored andcommitted
net/mlx4: Remove BUG_ON from ICM allocation routine
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: 5b0bf5e ("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>
1 parent 6496bbf commit c1d5f8f

File tree

1 file changed

+6
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+6
-1
lines changed

drivers/net/ethernet/mellanox/mlx4/icm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,
118118
if (!buf)
119119
return -ENOMEM;
120120

121+
if (offset_in_page(buf)) {
122+
dma_free_coherent(dev, PAGE_SIZE << order,
123+
buf, sg_dma_address(mem));
124+
return -ENOMEM;
125+
}
126+
121127
sg_set_buf(mem, buf, PAGE_SIZE << order);
122-
BUG_ON(mem->offset);
123128
sg_dma_len(mem) = PAGE_SIZE << order;
124129
return 0;
125130
}

0 commit comments

Comments
 (0)