+ if (list) {
+ /* User-specified probes. */
+ ret = append_list_to_probes(list);
+ if (ret) {
+ return ret;
+ }
+ } else {
+ /* Default probes. */
+ int def_len = ARRAY_SIZE(kern_modules_probes_default);
+
+ probes = zmalloc(sizeof(*probes) * def_len);
+ if (!probes) {
+ PERROR("malloc probe list");
+ return -ENOMEM;
+ }
+
+ nr_probes = probes_capacity = def_len;
+
+ for (i = 0; i < def_len; ++i) {
+ char* name = strdup(kern_modules_probes_default[i].name);
+
+ if (!name) {
+ PERROR("strdup probe item");
+ ret = -ENOMEM;
+ goto error;
+ }
+
+ probes[i].name = name;
+ }
+ }
+
+ /*
+ * Extra modules? Append them to current probes list.
+ */
+ if (kmod_extra_probes_list) {
+ list = kmod_extra_probes_list;
+ } else {
+ list = utils_get_extra_kmod_probes_list();
+ }
+
+ if (list) {
+ ret = append_list_to_probes(list);
+ if (ret) {
+ goto error;
+ }
+ }
+
+ /*
+ * Load probes modules now.
+ */
+ ret = modprobe_lttng(probes, nr_probes, LTTNG_MOD_OPTIONAL);
+ if (ret) {
+ goto error;
+ }
+ return ret;
+
+error:
+ free_probes();
+ return ret;