RDMA/cma: Fix rdma_resolve_route() memory leak
[sfrench/cifs-2.6.git] / drivers / infiniband / core / cma.c
index 9dfb07a16ab189e654c48f166d3b32555d79ae9e..420de383c03991f0831261c764c883047e1d3dc6 100644 (file)
@@ -2814,7 +2814,8 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv,
 
        cma_init_resolve_route_work(work, id_priv);
 
-       route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
+       if (!route->path_rec)
+               route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
        if (!route->path_rec) {
                ret = -ENOMEM;
                goto err1;