IB/core: Fix array length allocation

The new sysfs hw_counters code had an off by one in its array allocation
length.  Fix that and the comment along with it.

Reported-by: Mark Bloch <markb@mellanox.com>
Fixes: b40f4757da (IB/core: Make device counter infrastructure
dynamic)
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
Doug Ledford 2016-06-06 19:52:55 -04:00
Родитель 55c40648d3
Коммит 41aaa99fab
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -901,9 +901,12 @@ static void setup_hw_stats(struct ib_device *device, struct ib_port *port,
if (!stats->names || stats->num_counters <= 0) if (!stats->names || stats->num_counters <= 0)
goto err_free_stats; goto err_free_stats;
/*
* Two extra attribue elements here, one for the lifespan entry and
* one to NULL terminate the list for the sysfs core code
*/
hsag = kzalloc(sizeof(*hsag) + hsag = kzalloc(sizeof(*hsag) +
// 1 extra for the lifespan config entry sizeof(void *) * (stats->num_counters + 2),
sizeof(void *) * (stats->num_counters + 1),
GFP_KERNEL); GFP_KERNEL);
if (!hsag) if (!hsag)
goto err_free_stats; goto err_free_stats;