Merge tag 'stable/for-linus-3.9-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / drivers / infiniband / core / ucm.c
index 49b15ac..f2f6393 100644 (file)
@@ -176,7 +176,6 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
 static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
 {
        struct ib_ucm_context *ctx;
-       int result;
 
        ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
        if (!ctx)
@@ -187,17 +186,10 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
        ctx->file = file;
        INIT_LIST_HEAD(&ctx->events);
 
-       do {
-               result = idr_pre_get(&ctx_id_table, GFP_KERNEL);
-               if (!result)
-                       goto error;
-
-               mutex_lock(&ctx_id_mutex);
-               result = idr_get_new(&ctx_id_table, ctx, &ctx->id);
-               mutex_unlock(&ctx_id_mutex);
-       } while (result == -EAGAIN);
-
-       if (result)
+       mutex_lock(&ctx_id_mutex);
+       ctx->id = idr_alloc(&ctx_id_table, ctx, 0, 0, GFP_KERNEL);
+       mutex_unlock(&ctx_id_mutex);
+       if (ctx->id < 0)
                goto error;
 
        list_add_tail(&ctx->file_list, &file->ctxs);