OSDN Git Service

IB/mlx4: Fix memory leak in do_slave_init
authorDoug Ledford <dledford@redhat.com>
Thu, 9 Jul 2015 14:16:12 +0000 (10:16 -0400)
committerDoug Ledford <dledford@redhat.com>
Tue, 14 Jul 2015 17:20:15 +0000 (13:20 -0400)
We create a number of work structs to be queued up to a workqueue, and
on completion of the workqueue handler, the workqueue handler frees the
allocated memory.  If, however, we don't queue the work struct because
the device is going down, then we need to free the memory ourselves.

Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx4/main.c

index 064454a..1c59e47 100644 (file)
@@ -2692,6 +2692,8 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
                spin_lock_irqsave(&ibdev->sriov.going_down_lock, flags);
                if (!ibdev->sriov.is_going_down)
                        queue_work(ibdev->sriov.demux[i].ud_wq, &dm[i]->work);
+               else
+                       kfree(dm[i]);
                spin_unlock_irqrestore(&ibdev->sriov.going_down_lock, flags);
        }
 out: