NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/50357: warning message from anita



The following reply was made to PR install/50357; it has been noted by GNATS.

From: Paul Goyette <paul%whooppee.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: pkg/50357: warning message from anita
Date: Wed, 15 Jun 2016 09:24:59 +0800 (PHT)

 Here's a revised patch, which avoids dereferencing an unitialized 
 mi_name pointer for the "dummy_module" (which is used to make sure that 
 the linkset for module pointers is never empty).
 
 I plan to commit this on Friday unless there are any objections.
 
 Check for duplicate module names before loading modules that were
 "pushed" by the boot loader.  Under some circumstances, the boot
 loader still pushes in the module name for the root file system
 (particularly on amd64 INSTALL builds, where MEMORY_DISK_HOOKS and
 MEMORY_DISK_DYNAMIC are defined);  when this happens, we get a lot
 of "redefined symbol" error messages because the file system
 module is already loaded.
 
 This fix does not alter the behavior of pushing the file system
 name.  It simply avoids the redefined symbol errors by detecting
 that the module is already built-in to the kernel and not trying
 to load another copy.
 
 While here, differentiate the error message text between "failed
 to load" and "failed to fetch_info" conditions.
 
 
 Index: kern_module.c
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/kern_module.c,v
 retrieving revision 1.110
 diff -u -p -r1.110 kern_module.c
 --- kern_module.c	6 Feb 2016 22:48:07 -0000	1.110
 +++ kern_module.c	14 Jun 2016 11:39:08 -0000
 @@ -1235,6 +1235,8 @@ module_do_unload(const char *name, bool
   int
   module_prime(const char *name, void *base, size_t size)
   {
 +	__link_set_decl(modules, modinfo_t);
 +	modinfo_t *const *mip;
   	module_t *mod;
   	int error;
 
 @@ -1243,6 +1245,18 @@ module_prime(const char *name, void *bas
   		return ENOMEM;
   	}
 
 +	/* Check for duplicate modules */
 +
 +	__link_set_foreach(mip, modules) {
 +		if (*mip == &module_dummy)
 +			continue;
 +		if (strcmp((*mip)->mi_name, name) == 0) {
 +			module_error("module `%s' pushed by boot loader "
 +			    "already exists", name);
 +			kmem_free(mod, sizeof(*mod));
 +			return EEXIST;
 +		}
 +	}
   	error = kobj_load_mem(&mod->mod_kobj, name, base, size);
   	if (error != 0) {
   		kmem_free(mod, sizeof(*mod));
 @@ -1254,8 +1268,8 @@ module_prime(const char *name, void *bas
   	if (error != 0) {
   		kobj_unload(mod->mod_kobj);
   		kmem_free(mod, sizeof(*mod));
 -		module_error("unable to load `%s' pushed by boot loader, "
 -		    "error %d", name, error);
 +		module_error("unable to fetch_info for `%s' pushed by boot "
 +		    "loader, error %d", name, error);
   		return error;
   	}
 
 
 
 +------------------+--------------------------+------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 +------------------+--------------------------+------------------------+
 


Home | Main Index | Thread Index | Old Index