Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

module/decompress: use kvmalloc() consistently

We consistently switched from kmalloc() to vmalloc() in module
decompression to prevent potential memory allocation failures with large
modules, however vmalloc() is not as memory-efficient and fast as
kmalloc().

Since we don't know in general the size of the workspace required by the
decompression algorithm, it is more reasonable to use kvmalloc()
consistently, also considering that we don't have special memory
requirements here.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andrea Righi and committed by
Linus Torvalds
17fc8084 ca219be0

+4 -4
+4 -4
kernel/module/decompress.c
··· 100 100 s.next_in = buf + gzip_hdr_len; 101 101 s.avail_in = size - gzip_hdr_len; 102 102 103 - s.workspace = vmalloc(zlib_inflate_workspacesize()); 103 + s.workspace = kvmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); 104 104 if (!s.workspace) 105 105 return -ENOMEM; 106 106 ··· 138 138 out_inflate_end: 139 139 zlib_inflateEnd(&s); 140 140 out: 141 - vfree(s.workspace); 141 + kvfree(s.workspace); 142 142 return retval; 143 143 } 144 144 #elif defined(CONFIG_MODULE_COMPRESS_XZ) ··· 241 241 } 242 242 243 243 wksp_size = zstd_dstream_workspace_bound(header.windowSize); 244 - wksp = vmalloc(wksp_size); 244 + wksp = kvmalloc(wksp_size, GFP_KERNEL); 245 245 if (!wksp) { 246 246 retval = -ENOMEM; 247 247 goto out; ··· 284 284 retval = new_size; 285 285 286 286 out: 287 - vfree(wksp); 287 + kvfree(wksp); 288 288 return retval; 289 289 } 290 290 #else