diff options
author | Elliott Hughes <enh@google.com> | 2018-08-01 12:14:23 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-08-04 12:38:13 -0500 |
commit | fc655a04768cade9f42ad2d865d1a7a52e7f32dc (patch) | |
tree | a4197275580236bdfda5f8d305c9a134743002d3 /toys/pending | |
parent | d7c111f4c39de122cdd1ea41c8af67a609fc859a (diff) | |
download | toybox-fc655a04768cade9f42ad2d865d1a7a52e7f32dc.tar.gz |
Fix modprobe error handling.
modprobe was failing if you `modprobe a.ko`, then `modprobe b.ko` where b.ko
depends on a.ko --- b.ko will fail to load because a.ko is already loaded.
The code to handle this was incorrectly checking `rc` rather than `errno`
against EEXIST.
(We should pull the insmod.c equivalent of `ins_mod` out into lib/
and reuse it in modprobe.c, but I didn't want to get bogged down.)
Bug: https://issuetracker.google.com/112069618
Reported-by: Wen Xie <xiewen3@motorola.com>
Diffstat (limited to 'toys/pending')
-rw-r--r-- | toys/pending/modprobe.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c index 33a2a310..0c0cbc83 100644 --- a/toys/pending/modprobe.c +++ b/toys/pending/modprobe.c @@ -482,9 +482,9 @@ static int go_probe(struct module_s *m) // none of above is true insert the module. rc = ins_mod(fn, options); if (toys.optflags&FLAG_v) - printf("loaded %s '%s', rc:%d\n", fn, options, rc); - if (rc == EEXIST) rc = 0; - if (options) free(options); + printf("loaded %s '%s': %s\n", fn, options, strerror(errno)); + if (errno == EEXIST) rc = 0; + free(options); if (rc) { perror_msg("can't load module %s (%s)", m2->name, fn); break; |