From: Brian Behlendorf Date: Wed, 21 Jan 2015 17:21:51 +0000 (-0800) Subject: Fix GFP_KERNEL allocations flags X-Git-Tag: spl-0.6.4~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54cccfc2e30fa84463c056e8ad04b2be9448999e;p=spl Fix GFP_KERNEL allocations flags The kmem_vasprintf(), kmem_vsprintf(), kobj_open_file(), and vn_openat() functions should all use the kmem_flags_convert() function to generate the GFP_* flags. This ensures that they can be safely called in any context and the correct flags will be used. Signed-off-by: Brian Behlendorf Closes #426 --- diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index 914f0fb..e97d5f2 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -80,7 +80,7 @@ kmem_vasprintf(const char *fmt, va_list ap) do { va_copy(aq, ap); - ptr = kvasprintf(GFP_KERNEL, fmt, aq); + ptr = kvasprintf(kmem_flags_convert(KM_SLEEP), fmt, aq); va_end(aq); } while (ptr == NULL); @@ -96,7 +96,7 @@ kmem_asprintf(const char *fmt, ...) do { va_start(ap, fmt); - ptr = kvasprintf(GFP_KERNEL, fmt, ap); + ptr = kvasprintf(kmem_flags_convert(KM_SLEEP), fmt, ap); va_end(ap); } while (ptr == NULL); diff --git a/module/spl/spl-kobj.c b/module/spl/spl-kobj.c index 5b29fdb..4dd14ba 100644 --- a/module/spl/spl-kobj.c +++ b/module/spl/spl-kobj.c @@ -33,7 +33,7 @@ kobj_open_file(const char *name) vnode_t *vp; int rc; - file = kmalloc(sizeof(_buf_t), GFP_KERNEL); + file = kmalloc(sizeof(_buf_t), kmem_flags_convert(KM_SLEEP)); if (file == NULL) return ((_buf_t *)-1UL); diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index 97eb4ef..bce28a5 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -196,7 +196,7 @@ vn_openat(const char *path, uio_seg_t seg, int flags, int mode, ASSERT(vp == rootdir); len = strlen(path) + 2; - realpath = kmalloc(len, GFP_KERNEL); + realpath = kmalloc(len, kmem_flags_convert(KM_SLEEP)); if (!realpath) return (ENOMEM);