Browse code

cfg framework: set the handle before creating the cfg group

The handle must be set before the config group is created
because the related functions save the value for future use.

The tcp and sctp config handles are not initialized to the default
config struction. This cased a crash because orig_handle was set to
the initial value which is uninitialized.

Miklos Tirpak authored on 24/06/2011 13:10:51
Showing 1 changed files
... ...
@@ -141,6 +141,14 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
141 141
 		goto error;
142 142
 	}
143 143
 
144
+	/* The cfg variables are ready to use, let us set the handle
145
+	before passing the new definitions to the drivers.
146
+	We make the interface usable for the fixup functions
147
+	at this step
148
+	cfg_set_group() and cfg_new_group() need the handle to be set because
149
+	they save its original value. */
150
+	*handle = values;
151
+
144 152
 	group_name_len = strlen(group_name);
145 153
 	/* check for duplicates */
146 154
 	if ((group = cfg_lookup_group(group_name, group_name_len))) {
... ...
@@ -162,12 +170,6 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
162 162
 	}
163 163
 	group->dynamic = CFG_GROUP_STATIC;
164 164
 
165
-	/* The cfg variables are ready to use, let us set the handle
166
-	before passing the new definitions to the drivers.
167
-	We make the interface usable for the fixup functions
168
-	at this step */
169
-	*handle = values;
170
-
171 165
 	/* notify the drivers about the new config definition */
172 166
 	cfg_notify_drivers(group_name, group_name_len, def);
173 167