[openib-general] [PATCH] [RFC] cma_new_id can kfree on error instead of destroy_id

Krishna Kumar krkumar2 at in.ibm.com
Mon Oct 16 21:39:26 PDT 2006


cma_new_id() does not require to do destroy_id(), instead
it can kfree(), since nothing is allocated on that id.
Posting this as an RFC in case anyone feels that create_id
should be cleaned up by destroy_id (even if redundant).

Signed-off-by: Krishna Kumar <krkumar2 at in.ibm.com>
--------
diff -ruNp org/drivers/infiniband/core/cma.c new/drivers/infiniband/core/cma.c
--- org/drivers/infiniband/core/cma.c	2006-10-09 20:59:45.000000000 +0530
+++ new/drivers/infiniband/core/cma.c	2006-10-10 10:17:42.000000000 +0530
@@ -883,6 +883,7 @@ static struct rdma_id_private *cma_new_i
 	if (IS_ERR(id))
 		goto err;
 
+	id_priv = container_of(id, struct rdma_id_private, id);
 	cma_save_net_info(&id->route.addr, &listen_id->route.addr,
 			  ip_ver, port, src, dst);
 
@@ -891,7 +892,7 @@ static struct rdma_id_private *cma_new_i
 	rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths,
 			       GFP_KERNEL);
 	if (!rt->path_rec)
-		goto destroy_id;
+		goto free_id;
 
 	rt->path_rec[0] = *ib_event->param.req_rcvd.primary_path;
 	if (rt->num_paths == 2)
@@ -902,12 +903,11 @@ static struct rdma_id_private *cma_new_i
 	ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
 	rt->addr.dev_addr.dev_type = RDMA_NODE_IB_CA;
 
-	id_priv = container_of(id, struct rdma_id_private, id);
 	id_priv->state = CMA_CONNECT;
 	return id_priv;
 
-destroy_id:
-	rdma_destroy_id(id);
+free_id:
+	kfree(id_priv);
 err:
 	return NULL;
 }




More information about the general mailing list