@@ -309,6 +309,8 @@ EXPORT_SYMBOL(unregister_module_notifier);
309309
310310struct load_info {
311311 const char * name ;
312+ /* pointer to module in temporary copy, freed at end of load_module() */
313+ struct module * mod ;
312314 Elf_Ehdr * hdr ;
313315 unsigned long len ;
314316 Elf_Shdr * sechdrs ;
@@ -2947,14 +2949,13 @@ static int rewrite_section_headers(struct load_info *info, int flags)
29472949 * search for module section index etc), and do some basic section
29482950 * verification.
29492951 *
2950- * Return the temporary module pointer (we'll replace it with the final
2951- * one when we move the module sections around ).
2952+ * Set info->mod to the temporary copy of the module in info->hdr. The final one
2953+ * will be allocated in move_module( ).
29522954 */
2953- static struct module * setup_load_info (struct load_info * info , int flags )
2955+ static int setup_load_info (struct load_info * info , int flags )
29542956{
29552957 unsigned int i ;
29562958 int err ;
2957- struct module * mod ;
29582959
29592960 /* Set up the convenience variables */
29602961 info -> sechdrs = (void * )info -> hdr + info -> hdr -> e_shoff ;
@@ -2963,7 +2964,7 @@ static struct module *setup_load_info(struct load_info *info, int flags)
29632964
29642965 err = rewrite_section_headers (info , flags );
29652966 if (err )
2966- return ERR_PTR ( err ) ;
2967+ return err ;
29672968
29682969 /* Find internal symbols and strings. */
29692970 for (i = 1 ; i < info -> hdr -> e_shnum ; i ++ ) {
@@ -2980,30 +2981,30 @@ static struct module *setup_load_info(struct load_info *info, int flags)
29802981 if (!info -> index .mod ) {
29812982 pr_warn ("%s: No module found in object\n" ,
29822983 info -> name ?: "(missing .modinfo name field)" );
2983- return ERR_PTR ( - ENOEXEC ) ;
2984+ return - ENOEXEC ;
29842985 }
29852986 /* This is temporary: point mod into copy of data. */
2986- mod = (void * )info -> sechdrs [info -> index .mod ].sh_addr ;
2987+ info -> mod = (void * )info -> sechdrs [info -> index .mod ].sh_addr ;
29872988
29882989 /*
29892990 * If we didn't load the .modinfo 'name' field, fall back to
29902991 * on-disk struct mod 'name' field.
29912992 */
29922993 if (!info -> name )
2993- info -> name = mod -> name ;
2994+ info -> name = info -> mod -> name ;
29942995
29952996 if (info -> index .sym == 0 ) {
29962997 pr_warn ("%s: module has no symbols (stripped?)\n" , info -> name );
2997- return ERR_PTR ( - ENOEXEC ) ;
2998+ return - ENOEXEC ;
29982999 }
29993000
30003001 info -> index .pcpu = find_pcpusec (info );
30013002
30023003 /* Check module struct version now, before we try to use module. */
3003- if (!check_modstruct_version (info , mod ))
3004- return ERR_PTR ( - ENOEXEC ) ;
3004+ if (!check_modstruct_version (info , info -> mod ))
3005+ return - ENOEXEC ;
30053006
3006- return mod ;
3007+ return 0 ;
30073008}
30083009
30093010static int check_modinfo (struct module * mod , struct load_info * info , int flags )
@@ -3298,25 +3299,24 @@ core_param(module_blacklist, module_blacklist, charp, 0400);
32983299
32993300static struct module * layout_and_allocate (struct load_info * info , int flags )
33003301{
3301- /* Module within temporary copy. */
33023302 struct module * mod ;
33033303 unsigned int ndx ;
33043304 int err ;
33053305
3306- mod = setup_load_info (info , flags );
3307- if (IS_ERR ( mod ) )
3308- return mod ;
3306+ err = setup_load_info (info , flags );
3307+ if (err )
3308+ return ERR_PTR ( err ) ;
33093309
33103310 if (blacklisted (info -> name ))
33113311 return ERR_PTR (- EPERM );
33123312
3313- err = check_modinfo (mod , info , flags );
3313+ err = check_modinfo (info -> mod , info , flags );
33143314 if (err )
33153315 return ERR_PTR (err );
33163316
33173317 /* Allow arches to frob section contents and sizes. */
33183318 err = module_frob_arch_sections (info -> hdr , info -> sechdrs ,
3319- info -> secstrings , mod );
3319+ info -> secstrings , info -> mod );
33203320 if (err < 0 )
33213321 return ERR_PTR (err );
33223322
@@ -3335,11 +3335,11 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
33353335 /* Determine total sizes, and put offsets in sh_entsize. For now
33363336 this is done generically; there doesn't appear to be any
33373337 special cases for the architectures. */
3338- layout_sections (mod , info );
3339- layout_symtab (mod , info );
3338+ layout_sections (info -> mod , info );
3339+ layout_symtab (info -> mod , info );
33403340
33413341 /* Allocate and move to the final place */
3342- err = move_module (mod , info );
3342+ err = move_module (info -> mod , info );
33433343 if (err )
33443344 return ERR_PTR (err );
33453345
0 commit comments