Skip to content

Commit

Permalink
Fix GFP_KERNEL allocations flags
Browse files Browse the repository at this point in the history
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 <behlendorf1@llnl.gov>
Closes openzfs#426
  • Loading branch information
behlendorf committed Jan 21, 2015
1 parent 9099312 commit 54cccfc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions module/spl/spl-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion module/spl/spl-kobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion module/spl/spl-vnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 54cccfc

Please sign in to comment.