Re: [PATCH rdma-core 2/2] mlx5: Fix wrong bitmap table allocation size calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/29/2017 7:37 PM, Jason Gunthorpe wrote:
On Sun, Oct 29, 2017 at 03:01:10PM +0200, Yishai Hadas wrote:

diff --git a/providers/mlx5/buf.c b/providers/mlx5/buf.c
index 8196db6..0ba8188 100644
+++ b/providers/mlx5/buf.c
@@ -51,7 +51,7 @@ static int mlx5_bitmap_init(struct mlx5_bitmap *bitmap, uint32_t num,
  	bitmap->avail = num;
  	bitmap->mask = mask;
  	bitmap->avail = bitmap->max;
-	bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(uint32_t));
+	bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(long));

bitmap->table is sensibly set to a 'unsigned long' but here, and in
several other related macros, 'long' is used instead.. Looks weird to
mix and match the sigend and unsigned versions.

Generally, I prefer:
	bitmap->table = calloc(BITS_TO_LONGS(bitmap->max),
	                       sizeof(*bitmap->table));

PR was updated as of that suggestion:
https://github.com/linux-rdma/rdma-core/pull/235


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux