aboutsummaryrefslogtreecommitdiff
path: root/modutils/modutils-24.c
diff options
context:
space:
mode:
Diffstat (limited to 'modutils/modutils-24.c')
-rw-r--r--modutils/modutils-24.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c
index e5ff54d29..a878e740c 100644
--- a/modutils/modutils-24.c
+++ b/modutils/modutils-24.c
@@ -3783,12 +3783,20 @@ int FAST_FUNC bb_init_module_24(const char *m_filename, const char *options)
3783 int m_has_modinfo; 3783 int m_has_modinfo;
3784#endif 3784#endif
3785 char *image; 3785 char *image;
3786 size_t image_size = 64 * 1024 * 1024; 3786 size_t image_size;
3787 3787 bool mmaped;
3788 /* Load module into memory and unzip if compressed */ 3788
3789 image = xmalloc_open_zipped_read_close(m_filename, &image_size); 3789 image_size = INT_MAX - 4095;
3790 if (!image) 3790 mmaped = 0;
3791 return EXIT_FAILURE; 3791 image = try_to_mmap_module(m_filename, &image_size);
3792 if (image) {
3793 mmaped = 1;
3794 } else {
3795 /* Load module into memory and unzip if compressed */
3796 image = xmalloc_open_zipped_read_close(m_filename, &image_size);
3797 if (!image)
3798 return EXIT_FAILURE;
3799 }
3792 3800
3793 m_name = xstrdup(bb_basename(m_filename)); 3801 m_name = xstrdup(bb_basename(m_filename));
3794 /* "module.o[.gz]" -> "module" */ 3802 /* "module.o[.gz]" -> "module" */
@@ -3901,7 +3909,10 @@ int FAST_FUNC bb_init_module_24(const char *m_filename, const char *options)
3901 exit_status = EXIT_SUCCESS; 3909 exit_status = EXIT_SUCCESS;
3902 3910
3903 out: 3911 out:
3904 free(image); 3912 if (mmaped)
3913 munmap(image, image_size);
3914 else
3915 free(image);
3905 free(m_name); 3916 free(m_name);
3906 3917
3907 return exit_status; 3918 return exit_status;