Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932360AbbGGPLW (ORCPT ); Tue, 7 Jul 2015 11:11:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43750 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757500AbbGGPLM (ORCPT ); Tue, 7 Jul 2015 11:11:12 -0400 Date: Tue, 7 Jul 2015 11:11:11 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Mike Snitzer cc: "Alasdair G. Kergon" , Edward Thornber , Andrew Morton , David Rientjes , Vivek Goyal , linux-kernel@vger.kernel.org, linux-mm@kvack.org, dm-devel@redhat.com Subject: [PATCH 4/7] dm: use kvmalloc In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2271 Lines: 67 Use the function kvmalloc to allocate ioctl parameters. Signed-off-by: Mikulas Patocka --- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/