RDMA/cm: check that idr_pre_get didn't fail and clean it in error flow
PATCH 1/1 RDMA/cm: check that idr_pre_get didn't fail and clean it in error flow
The function idr_pre_get may fail, so there is a need to check the status of it. Since this function allocate resources, we need to clean them during the resource cleaning in case of error.
---
drivers/infiniband/core/cm.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)
drivers/infiniband/core/cm.c +13 -7
@@ -3843,28 +3843,34 @@ static int __init ib_cm_init(void) cm.remote_sidr_table =RB_ROOT ;idr_init (&cm.local_id_table);get_random_bytes (&cm.random_id_operand,sizeof cm.random_id_operand); -idr_pre_get (&cm.local_id_table,GFP_KERNEL ); +if (!idr_pre_get (&cm.local_id_table,GFP_KERNEL )) +return -ENOMEM ; +INIT_LIST_HEAD (&cm.timewait_list); ret =class_register (&cm_class); -if (ret) -return -ENOMEM ; +if (ret) { + ret = -ENOMEM ; + goto error1; + } cm.wq =create_workqueue ("ib_cm" );if (!cm.wq) { ret = -ENOMEM ; - goto error1; + goto error2; } ret =ib_register_client (&cm_client);if (ret) - goto error2; + goto error3;return 0 ; -error2: +error3:destroy_workqueue (cm.wq); -error1: +error2:class_unregister (&cm_class); +error1: +idr_destroy (&cm.local_id_table);return ret; }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 201111031519.48018.dotanb-g2bIKuvJtcQanlnWow0HJg@public.gmane.org
Quoted 3 lines
The function
idr_pre_getmay fail, so there is a need to check the status of it. Since this function allocate resources, we need to clean them during the resource cleaning in case of error.
We should add the cleanup code below, but I don't think we care if idr_pre_get fails here. We'll just try again later.
drivers/infiniband/core/cm.c static int __init ib_cm_init(void) · line 3875
Quoted 11 lines
drivers/infiniband/core/cm.c +4
-2-error2: +error3:destroy_workqueue (cm.wq); -error1: +error2:class_unregister (&cm_class); +error1: +idr_destroy (&cm.local_id_table);return ret; }
- Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CALvMawoJWFaTRLvmbR7s14EMLce3dZx=tnKFu+vq1ZfnnUHZJA@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CALvMawoJWFaTRLvmbR7s14EMLce3dZx=tnKFu+vq1ZfnnUHZJA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 1 line
Do you want me to resent a new patch only with the cleanup code?
If you have time, please do.
Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html