aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index ad39be059..945483327 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -100,8 +100,7 @@ static int FAST_FUNC config_file_action(const char *filename,
100 } 100 }
101 config_close(p); 101 config_close(p);
102error: 102error:
103 if (ENABLE_FEATURE_CLEAN_UP) 103 RELEASE_CONFIG_BUFFER(modname);
104 RELEASE_CONFIG_BUFFER(modname);
105 return rc; 104 return rc;
106} 105}
107 106
@@ -141,8 +140,13 @@ static int do_modprobe(struct modprobe_conf *conf, const char *module)
141 int rc = -1; 140 int rc = -1;
142 141
143 p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, fopen_for_read); 142 p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, fopen_for_read);
143 /* Modprobe does not work at all without modprobe.dep,
144 * even if the full module name is given. Returning error here
145 * was making us later confuse user with this message:
146 * "module /full/path/to/existing/file/module.ko not found".
147 * It's better to die immediately, with good message: */
144 if (p == NULL) 148 if (p == NULL)
145 goto error; 149 bb_perror_msg_and_die("can't open '%s'", CONFIG_DEFAULT_DEPMOD_FILE);
146 150
147 while (config_read(p, tokens, 2, 1, "# \t", PARSE_NORMAL)) { 151 while (config_read(p, tokens, 2, 1, "# \t", PARSE_NORMAL)) {
148 colon = last_char_is(tokens[0], ':'); 152 colon = last_char_is(tokens[0], ':');
@@ -179,23 +183,21 @@ static int do_modprobe(struct modprobe_conf *conf, const char *module)
179 rc = bb_init_module(fn, options); 183 rc = bb_init_module(fn, options);
180 if (rc == 0) 184 if (rc == 0)
181 llist_add_to(&loaded, xstrdup(modname)); 185 llist_add_to(&loaded, xstrdup(modname));
182 if (ENABLE_FEATURE_CLEAN_UP) 186 free(options);
183 free(options);
184 } 187 }
185 188
186 if (ENABLE_FEATURE_CLEAN_UP) 189 free(fn);
187 free(fn);
188 } 190 }
189 191
190error_not_found: 192 error_not_found:
191 config_close(p); 193 config_close(p);
192error: 194
193 if (ENABLE_FEATURE_CLEAN_UP)
194 RELEASE_CONFIG_BUFFER(modname);
195 if (rc > 0 && !(option_mask32 & INSMOD_OPT_SILENT)) 195 if (rc > 0 && !(option_mask32 & INSMOD_OPT_SILENT))
196 bb_error_msg("failed to %sload module %s: %s", 196 bb_error_msg("failed to %sload module %s: %s",
197 (option_mask32 & MODPROBE_OPT_REMOVE) ? "un" : "", 197 (option_mask32 & MODPROBE_OPT_REMOVE) ? "un" : "",
198 module, moderror(rc)); 198 module, moderror(rc));
199
200 RELEASE_CONFIG_BUFFER(modname);
199 return rc; 201 return rc;
200} 202}
201 203
@@ -278,8 +280,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
278 char *realname = llist_pop(&conf->aliases); 280 char *realname = llist_pop(&conf->aliases);
279 if (check_blacklist(conf, realname)) 281 if (check_blacklist(conf, realname))
280 do_modprobe(conf, realname); 282 do_modprobe(conf, realname);
281 if (ENABLE_FEATURE_CLEAN_UP) 283 free(realname);
282 free(realname);
283 } 284 }
284 } 285 }
285 argv++; 286 argv++;