lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1450253304-4156-1-git-send-email-puck.chen@hisilicon.com>
Date:	Wed, 16 Dec 2015 16:08:24 +0800
From:	Chen Feng <puck.chen@...ilicon.com>
To:	<matt@...eblueprint.co.uk>, <ard.biesheuvel@...aro.org>,
	<jdelvare@...e.de>, <Sudeep.Holla@....com>,
	<lorenzo.pieralisi@....com>, <ivan.khoronzhuk@...ballogic.com>,
	<linux-kernel@...r.kernel.org>, <puck.chen@...ilicon.com>,
	<yudongbin@...ilicon.com>, <saberlily.xia@...ilicon.com>,
	<suzhuangluan@...ilicon.com>, <kong.kongxinwei@...ilicon.com>,
	<xuyiping@...ilicon.com>, <z.liuxinliang@...ilicon.com>,
	<puck.chen@...yun.com>, <weidong2@...ilicon.com>, <w.f@...wei.com>
CC:	<qijiwen@...ilicon.com>, <peter.panshilin@...ilicon.com>,
	<dan.zhao@...ilicon.com>, <linuxarm@...wei.com>
Subject: [PATCH] firmware: Change the page arrary alloc to vmalloc

No need to use use continuous memory, it may be fail
when memory deeply fragmented.

Signed-off-by: Chen Feng <puck.chen@...ilicon.com>
Signed-off-by: Xia Qing <saberlily.xia@...ilicon.com>
---
 drivers/base/firmware_class.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 8524450..ff8672d 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -257,7 +257,7 @@ static void __fw_free_buf(struct kref *ref)
 		vunmap(buf->data);
 		for (i = 0; i < buf->nr_pages; i++)
 			__free_page(buf->pages[i]);
-		kfree(buf->pages);
+		vfree(buf->pages);
 	} else
 #endif
 		vfree(buf->data);
@@ -660,7 +660,7 @@ static ssize_t firmware_loading_store(struct device *dev,
 		if (!test_bit(FW_STATUS_DONE, &fw_buf->status)) {
 			for (i = 0; i < fw_buf->nr_pages; i++)
 				__free_page(fw_buf->pages[i]);
-			kfree(fw_buf->pages);
+			vfree(fw_buf->pages);
 			fw_buf->pages = NULL;
 			fw_buf->page_array_size = 0;
 			fw_buf->nr_pages = 0;
@@ -770,8 +770,7 @@ static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
 					 buf->page_array_size * 2);
 		struct page **new_pages;
 
-		new_pages = kmalloc(new_array_size * sizeof(void *),
-				    GFP_KERNEL);
+		new_pages = vmalloc(new_array_size * sizeof(void *));
 		if (!new_pages) {
 			fw_load_abort(fw_priv);
 			return -ENOMEM;
@@ -780,7 +779,7 @@ static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
 		       buf->page_array_size * sizeof(void *));
 		memset(&new_pages[buf->page_array_size], 0, sizeof(void *) *
 		       (new_array_size - buf->page_array_size));
-		kfree(buf->pages);
+		vfree(buf->pages);
 		buf->pages = new_pages;
 		buf->page_array_size = new_array_size;
 	}
-- 
1.9.1

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ