git: ecf710f0e04e - main - kern linker: Do not retry loading modules on EEXIST

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Tue, 07 Nov 2023 04:48:35 UTC
The branch main has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=ecf710f0e04e3314a492747124166ccb7cf4019e

commit ecf710f0e04e3314a492747124166ccb7cf4019e
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-11-07 04:45:25 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-11-07 04:45:25 +0000

    kern linker: Do not retry loading modules on EEXIST
    
    LINKER_LOAD_FILE() calls linker_load_dependencies() which will return
    EEXIST in case the module to be loaded has already been compiled into
    the kernel. Since the format of the module is now recognized then there
    is no need to retry loading with a different linker, otherwise the
    userland will get misleading error number ENOEXEC.
    
    PR:             274936
    Reviewed by:    dfr
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D42474
---
 sys/kern/kern_linker.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 2367bf35da76..c6eb0273c39d 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -461,8 +461,11 @@ linker_load_file(const char *filename, linker_file_t *result)
 		 * If we got something other than ENOENT, then it exists but
 		 * we cannot load it for some other reason.
 		 */
-		if (error != ENOENT)
+		if (error != ENOENT) {
 			foundfile = 1;
+			if (error == EEXIST)
+				break;
+		}
 		if (lf) {
 			error = linker_file_register_modules(lf);
 			if (error == EEXIST) {