Skip to content

Commit

Permalink
IB/core: Fix array length allocation
Browse files Browse the repository at this point in the history
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 <[email protected]>
Fixes: b40f475 (IB/core: Make device counter infrastructure
dynamic)
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
dledford committed Jun 7, 2016
1 parent 55c4064 commit 41aaa99
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/infiniband/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,12 @@ static void setup_hw_stats(struct ib_device *device, struct ib_port *port,
if (!stats->names || stats->num_counters <= 0)
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) +
// 1 extra for the lifespan config entry
sizeof(void *) * (stats->num_counters + 1),
sizeof(void *) * (stats->num_counters + 2),
GFP_KERNEL);
if (!hsag)
goto err_free_stats;
Expand Down

0 comments on commit 41aaa99

Please sign in to comment.