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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 16 May 2009 21:54:18 +0800
From:	tom.leiming@...il.com
To:	arjan@...radead.org
Cc:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	cornelia.huck@...ibm.com, Ming Lei <tom.leiming@...il.com>
Subject: [PATCH 2/2] driver core:firmware:fix request_firmware_nowait

From: Ming Lei <tom.leiming@...il.com>

request_firmware_nowait declares it can be called in non-sleep contexts,
but kthead_run called by request_firmware_nowait may sleep. So use
async_run_inatomic to start thread to request firmware.

Signed-off-by: Ming Lei <tom.leiming@...il.com>
---
 drivers/base/firmware_class.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d186149..99cb21e 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -19,6 +19,7 @@
 #include <linux/kthread.h>
 #include <linux/highmem.h>
 #include <linux/firmware.h>
+#include <linux/async.h>
 #include "base.h"
 
 #define to_dev(obj) container_of(obj, struct device, kobj)
@@ -582,15 +583,15 @@ struct firmware_work {
 	int uevent;
 };
 
-static int
-request_firmware_work_func(void *arg)
+static void
+request_firmware_work_func(void *arg, async_cookie_t cookie)
 {
 	struct firmware_work *fw_work = arg;
 	const struct firmware *fw;
 	int ret;
 	if (!arg) {
 		WARN_ON(1);
-		return 0;
+		return;
 	}
 	ret = _request_firmware(&fw, fw_work->name, fw_work->device,
 		fw_work->uevent);
@@ -602,7 +603,6 @@ request_firmware_work_func(void *arg)
 	}
 	module_put(fw_work->module);
 	kfree(fw_work);
-	return ret;
 }
 
 /**
@@ -626,7 +626,7 @@ request_firmware_nowait(
 	const char *name, struct device *device, void *context,
 	void (*cont)(const struct firmware *fw, void *context))
 {
-	struct task_struct *task;
+	int ret;
 	struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work),
 						GFP_ATOMIC);
 
@@ -646,14 +646,12 @@ request_firmware_nowait(
 		.uevent = uevent,
 	};
 
-	task = kthread_run(request_firmware_work_func, fw_work,
-			    "firmware/%s", name);
-
-	if (IS_ERR(task)) {
+	ret = async_run_inatomic(request_firmware_work_func, fw_work);
+	if (ret) {
 		fw_work->cont(NULL, fw_work->context);
 		module_put(fw_work->module);
 		kfree(fw_work);
-		return PTR_ERR(task);
+		return ret;
 	}
 	return 0;
 }
-- 
1.6.0.GIT

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