From fc655a04768cade9f42ad2d865d1a7a52e7f32dc Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 1 Aug 2018 12:14:23 -0700 Subject: 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 --- toys/pending/modprobe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toys/pending') 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; -- cgit v1.2.3