* [PATCH] RDMA/cm: check that idr_pre_get didn't fail and clean it in error flow
@ 2011-11-03 13:19 Dotan Barak
[not found] ` <201111031519.48018.dotanb-g2bIKuvJtcQanlnWow0HJg@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Dotan Barak @ 2011-11-03 13:19 UTC (permalink / raw)
To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w, roland-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
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.
Signed-off-by: Dotan Barak <dotanb-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Reviewed-by: Jack Morgenstein <jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
---
drivers/infiniband/core/cm.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 4104ea2..31df1b4 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] RDMA/cm: check that idr_pre_get didn't fail and clean it in error flow
[not found] ` <201111031519.48018.dotanb-g2bIKuvJtcQanlnWow0HJg@public.gmane.org>
@ 2011-11-03 13:52 ` Hefty, Sean
[not found] ` <CALvMawoJWFaTRLvmbR7s14EMLce3dZx=tnKFu+vq1ZfnnUHZJA@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Hefty, Sean @ 2011-11-03 13:52 UTC (permalink / raw)
To: Dotan Barak, roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> 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.
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.
> -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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] RDMA/cm: check that idr_pre_get didn't fail and clean it in error flow
[not found] ` <CALvMawoJWFaTRLvmbR7s14EMLce3dZx=tnKFu+vq1ZfnnUHZJA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-11-03 16:59 ` Hefty, Sean
0 siblings, 0 replies; 3+ messages in thread
From: Hefty, Sean @ 2011-11-03 16:59 UTC (permalink / raw)
To: Dotan Barak
Cc: roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-03 16:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03 13:19 [PATCH] RDMA/cm: check that idr_pre_get didn't fail and clean it in error flow Dotan Barak
[not found] ` <201111031519.48018.dotanb-g2bIKuvJtcQanlnWow0HJg@public.gmane.org>
2011-11-03 13:52 ` Hefty, Sean
[not found] ` <CALvMawoJWFaTRLvmbR7s14EMLce3dZx=tnKFu+vq1ZfnnUHZJA@mail.gmail.com>
[not found] ` <CALvMawoJWFaTRLvmbR7s14EMLce3dZx=tnKFu+vq1ZfnnUHZJA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-03 16:59 ` Hefty, Sean
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox