Check for context name duplicata
[lttng-modules.git] / lttng-context-perf-counters.c
index 5327e6ef06956707a914d15c3d56e9924291d06b..2f7132fbf26bf8db8aa9897fbfcee73cbc97e143 100644 (file)
@@ -170,6 +170,10 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
                ret = -ENOMEM;
                goto append_context_error;
        }
+       if (lttng_find_context(*ctx, name_alloc))  {
+               ret = -EEXIST;
+               goto find_error;
+       }
 
 #ifdef CONFIG_HOTPLUG_CPU
        field->u.perf_counter.nb.notifier_call =
@@ -217,6 +221,7 @@ counter_error:
 #ifdef CONFIG_HOTPLUG_CPU
        unregister_cpu_notifier(&field->u.perf_counter.nb);
 #endif
+find_error:
        lttng_remove_context_field(ctx, field);
 append_context_error:
        kfree(name_alloc);
This page took 0.023008 seconds and 4 git commands to generate.