diff options
author | Michal Hocko <mhocko@suse.com> | 2017-05-08 18:57:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-08 20:15:13 -0400 |
commit | d224e938189771dbd1e3b68ee8603a949bee76bb (patch) | |
tree | a1421bda5284b52c06f02970912bf920a405f8e4 /drivers/md/dm-ioctl.c | |
parent | da6bc57a8f02dd90d07071b4cd067f2de26c9192 (diff) |
drivers/md/dm-ioctl.c: use kvmalloc rather than opencoded variant
copy_params uses kmalloc with vmalloc fallback. We already have a
helper for that - kvmalloc. This caller requires GFP_NOIO semantic so
it hasn't been converted with many others by previous patches. All we
need to achieve this semantic is to use the scope
memalloc_noio_{save,restore} around kvmalloc.
Link: http://lkml.kernel.org/r/20170306103327.2766-4-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r-- | drivers/md/dm-ioctl.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 2d5d7064acbf..0555b4410e05 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -1691,6 +1691,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern | |||
1691 | struct dm_ioctl *dmi; | 1691 | struct dm_ioctl *dmi; |
1692 | int secure_data; | 1692 | int secure_data; |
1693 | const size_t minimum_data_size = offsetof(struct dm_ioctl, data); | 1693 | const size_t minimum_data_size = offsetof(struct dm_ioctl, data); |
1694 | unsigned noio_flag; | ||
1694 | 1695 | ||
1695 | if (copy_from_user(param_kernel, user, minimum_data_size)) | 1696 | if (copy_from_user(param_kernel, user, minimum_data_size)) |
1696 | return -EFAULT; | 1697 | return -EFAULT; |
@@ -1713,15 +1714,9 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern | |||
1713 | * Use kmalloc() rather than vmalloc() when we can. | 1714 | * Use kmalloc() rather than vmalloc() when we can. |
1714 | */ | 1715 | */ |
1715 | dmi = NULL; | 1716 | dmi = NULL; |
1716 | if (param_kernel->data_size <= KMALLOC_MAX_SIZE) | 1717 | noio_flag = memalloc_noio_save(); |
1717 | dmi = kmalloc(param_kernel->data_size, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN); | 1718 | dmi = kvmalloc(param_kernel->data_size, GFP_KERNEL); |
1718 | 1719 | memalloc_noio_restore(noio_flag); | |
1719 | if (!dmi) { | ||
1720 | unsigned noio_flag; | ||
1721 | noio_flag = memalloc_noio_save(); | ||
1722 | dmi = __vmalloc(param_kernel->data_size, GFP_NOIO | __GFP_HIGH | __GFP_HIGHMEM, PAGE_KERNEL); | ||
1723 | memalloc_noio_restore(noio_flag); | ||
1724 | } | ||
1725 | 1720 | ||
1726 | if (!dmi) { | 1721 | if (!dmi) { |
1727 | if (secure_data && clear_user(user, param_kernel->data_size)) | 1722 | if (secure_data && clear_user(user, param_kernel->data_size)) |