summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2016-06-07 07:43:46 -0400
committerDoug Ledford <dledford@redhat.com>2016-06-07 09:50:52 -0400
commit495fbae6e2c115099921ba33b1e1bea1190b5280 (patch)
tree3118b46a560246c847c4674a19084bc4f9d01d31
parent41aaa99fab6ceaa4b533c2b6ad4913987ddb3ddc (diff)
IB/core: fix error unwind in sysfs hw counters code
Between the initial and final versions of the function setup_hw_stats, the order of variable initialization was changed. However, the unwind flow on error did not properly keep up with the flow changes. Make the unwind flow match a proper unwind of the allocation flow, then remove no longer needed variable initializations. Fixes: b40f4757daa1 (IB/core: Make device counter infrastructure dynamic) Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/core/sysfs.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 2bc43444841b..35d0d47e6f8c 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -889,9 +889,9 @@ static struct attribute *alloc_hsa_lifespan(char *name, u8 port_num)
static void setup_hw_stats(struct ib_device *device, struct ib_port *port,
u8 port_num)
{
- struct attribute_group *hsag = NULL;
+ struct attribute_group *hsag;
struct rdma_hw_stats *stats;
- int i = 0, ret;
+ int i, ret;
stats = device->alloc_hw_stats(device, port_num);
@@ -914,7 +914,7 @@ static void setup_hw_stats(struct ib_device *device, struct ib_port *port,
ret = device->get_hw_stats(device, stats, port_num,
stats->num_counters);
if (ret != stats->num_counters)
- goto err;
+ goto err_free_hsag;
stats->timestamp = jiffies;
@@ -951,6 +951,7 @@ static void setup_hw_stats(struct ib_device *device, struct ib_port *port,
err:
for (; i >= 0; i--)
kfree(hsag->attrs[i]);
+err_free_hsag:
kfree(hsag);
err_free_stats:
kfree(stats);