Skip to content

Commit f25d20b

Browse files
Dotan BarakSomasundaram Krishnasamy
authored andcommitted
net/mlx4_core: add sanity check when creating bitmap structure
If a user tries to allocate bitmap structure with invalid values, this may cause a kernel panic. Signed-off-by: Dotan Barak <[email protected]> Reviewed-by: Yishai Hadas <[email protected]> (Ported from Mellanox OFED 2.4) Signed-off-by: Mukesh Kacker <[email protected]> Orabug: 27510503 (cherry picked from commit a6f7793) cherry-pick-repo=linux-uek.git Signed-off-by: Qing Huang <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 499578c commit f25d20b

File tree

1 file changed

+4
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt,
173173
int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
174174
u32 reserved_bot, u32 reserved_top)
175175
{
176+
/* sanity check */
177+
if (num <= (u64)reserved_top + reserved_bot)
178+
return -EINVAL;
179+
176180
/* num must be a power of 2 */
177181
if (num != roundup_pow_of_two(num))
178182
return -EINVAL;

0 commit comments

Comments
 (0)