diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-08-24 16:05:04 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2020-08-24 16:25:05 -0400 |
commit | cd9892e543845e045142ed29e4a5a9ce446a205e (patch) | |
tree | 1556289a5366d5cdfff32f9669cf748e39ed5063 /include/linux/vmalloc.h | |
parent | 21ade396535e51503511f42ea06d58e25c0646c5 (diff) |
Update bcachefs sources to 10ab39f2fa bcachefs: Improvements to the journal read error paths
Diffstat (limited to 'include/linux/vmalloc.h')
-rw-r--r-- | include/linux/vmalloc.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index c91e3a80..efcc1912 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -12,7 +12,7 @@ #define vfree(p) free(p) -static inline void *__vmalloc(unsigned long size, gfp_t gfp_mask, unsigned prot) +static inline void *__vmalloc(unsigned long size, gfp_t gfp_mask) { void *p; @@ -22,26 +22,36 @@ static inline void *__vmalloc(unsigned long size, gfp_t gfp_mask, unsigned prot) if (!p) return NULL; - if (prot == PAGE_KERNEL_EXEC && - mprotect(p, size, PROT_READ|PROT_WRITE|PROT_EXEC)) { + if (gfp_mask & __GFP_ZERO) + memset(p, 0, size); + + return p; +} + +static inline void *vmalloc_exec(unsigned long size, gfp_t gfp_mask) +{ + void *p; + + p = __vmalloc(size, gfp_mask); + if (!p) + return NULL; + + if (mprotect(p, size, PROT_READ|PROT_WRITE|PROT_EXEC)) { vfree(p); return NULL; } - if (gfp_mask & __GFP_ZERO) - memset(p, 0, size); - return p; } static inline void *vmalloc(unsigned long size) { - return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL); + return __vmalloc(size, GFP_KERNEL); } static inline void *vzalloc(unsigned long size) { - return __vmalloc(size, GFP_KERNEL|__GFP_ZERO, PAGE_KERNEL); + return __vmalloc(size, GFP_KERNEL|__GFP_ZERO); } #endif /* __TOOLS_LINUX_VMALLOC_H */ |