[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 7 Jul 2015 11:11:11 -0400 (EDT)
From: Mikulas Patocka <mpatocka@...hat.com>
To: Mike Snitzer <msnitzer@...hat.com>
cc: "Alasdair G. Kergon" <agk@...hat.com>,
Edward Thornber <thornber@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
David Rientjes <rientjes@...gle.com>,
Vivek Goyal <vgoyal@...hat.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, dm-devel@...hat.com
Subject: [PATCH 4/7] dm: use kvmalloc
Use the function kvmalloc to allocate ioctl parameters.
Signed-off-by: Mikulas Patocka <mpatocka@...hat.com>
---
drivers/md/dm-ioctl.c | 26 +++++---------------------
drivers/md/dm-table.c | 37 +++++++++++++++++++++++++++++++++++++
include/linux/device-mapper.h | 2 ++
3 files changed, 44 insertions(+), 21 deletions(-)
Index: linux-4.1/drivers/md/dm-ioctl.c
===================================================================
--- linux-4.1.orig/drivers/md/dm-ioctl.c 2015-07-02 19:21:15.000000000 +0200
+++ linux-4.1/drivers/md/dm-ioctl.c 2015-07-02 19:21:21.000000000 +0200
@@ -1676,12 +1676,8 @@ static void free_params(struct dm_ioctl
if (param_flags & DM_WIPE_BUFFER)
memset(param, 0, param_size);
- if (param_flags & DM_PARAMS_ALLOC) {
- if (is_vmalloc_addr(param))
- vfree(param);
- else
- kfree(param);
- }
+ if (param_flags & DM_PARAMS_ALLOC)
+ kvfree(param);
}
static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kernel,
@@ -1712,21 +1708,7 @@ static int copy_params(struct dm_ioctl _
* Try to avoid low memory issues when a device is suspended.
* Use kmalloc() rather than vmalloc() when we can.
*/
- dmi = NULL;
- if (param_kernel->data_size <= KMALLOC_MAX_SIZE) {
- dmi = kmalloc(param_kernel->data_size, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
- if (dmi)
- *param_flags |= DM_PARAMS_ALLOC;
- }
-
- if (!dmi) {
- unsigned noio_flag;
- noio_flag = memalloc_noio_save();
- dmi = __vmalloc(param_kernel->data_size, GFP_NOIO | __GFP_REPEAT | __GFP_HIGH | __GFP_HIGHMEM, PAGE_KERNEL);
- memalloc_noio_restore(noio_flag);
- if (dmi)
- *param_flags |= DM_PARAMS_ALLOC;
- }
+ dmi = kvmalloc(param_kernel->data_size, GFP_NOIO);
if (!dmi) {
if (secure_data && clear_user(user, param_kernel->data_size))
@@ -1734,6 +1716,8 @@ static int copy_params(struct dm_ioctl _
return -ENOMEM;
}
+ *param_flags |= DM_PARAMS_ALLOC;
+
if (copy_from_user(dmi, user, param_kernel->data_size))
goto bad;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists