]> git.karo-electronics.de Git - linux-beck.git/commitdiff
IB/core: Fix array length allocation
authorDoug Ledford <dledford@redhat.com>
Mon, 6 Jun 2016 23:52:55 +0000 (19:52 -0400)
committerDoug Ledford <dledford@redhat.com>
Tue, 7 Jun 2016 13:42:21 +0000 (09:42 -0400)
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>
drivers/infiniband/core/sysfs.c

index ed04a7bd44818a0a531233e772ce9fd502dc0846..2bc43444841b128d7615962b8a7931bb14d2865b 100644 (file)
@@ -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;