diff options
author | Doug Ledford <dledford@redhat.com> | 2016-06-06 19:52:55 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-06-07 09:42:21 -0400 |
commit | 41aaa99fab6ceaa4b533c2b6ad4913987ddb3ddc (patch) | |
tree | ac82511a648fc9eab5c35010b39578a72aa779b7 | |
parent | 55c40648d31d0d97608f266955b8afae74e2b686 (diff) |
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: b40f4757daa1 (IB/core: Make device counter infrastructure
dynamic)
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index ed04a7bd4481..2bc43444841b 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -901,9 +901,12 @@ static void setup_hw_stats(struct ib_device *device, struct ib_port *port, | |||
901 | if (!stats->names || stats->num_counters <= 0) | 901 | if (!stats->names || stats->num_counters <= 0) |
902 | goto err_free_stats; | 902 | goto err_free_stats; |
903 | 903 | ||
904 | /* | ||
905 | * Two extra attribue elements here, one for the lifespan entry and | ||
906 | * one to NULL terminate the list for the sysfs core code | ||
907 | */ | ||
904 | hsag = kzalloc(sizeof(*hsag) + | 908 | hsag = kzalloc(sizeof(*hsag) + |
905 | // 1 extra for the lifespan config entry | 909 | sizeof(void *) * (stats->num_counters + 2), |
906 | sizeof(void *) * (stats->num_counters + 1), | ||
907 | GFP_KERNEL); | 910 | GFP_KERNEL); |
908 | if (!hsag) | 911 | if (!hsag) |
909 | goto err_free_stats; | 912 | goto err_free_stats; |