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]
Date:	Wed, 11 Jul 2012 12:19:44 +0545
From:	Devendra Naga <devendra.aaru@...il.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Ben Chan <benchan@...omium.org>, Sage Ahn <syahn@...semi.com>,
	Paul Stewart <pstew@...omium.org>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Cc:	Devendra Naga <devendra.aaru@...il.com>
Subject: [PATCH] staging/gdm72xx: use kthread APIs

This patch modifies the kthread usage in the gdm_usb code, and tries to
use the kthread APIs better.

Actually the task_struct is taken as global as the limitation of priv.
we run the kthread before we allocate the priv.

did only compilation test, but not the insmod, check ps ax for kthread and
rmmod and see the thread is killed kind of tests.

There were no checks while kthread_run may fail, returing some error which can be seen by using PTR_ERR.

Signed-off-by: Devendra Naga <devendra.aaru@...il.com>
---
 drivers/staging/gdm72xx/gdm_usb.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c
index 89268c7..126150d 100644
--- a/drivers/staging/gdm72xx/gdm_usb.c
+++ b/drivers/staging/gdm72xx/gdm_usb.c
@@ -46,7 +46,6 @@ MODULE_DEVICE_TABLE(usb, id_table);
 static DECLARE_WAIT_QUEUE_HEAD(k_wait);
 static LIST_HEAD(k_list);
 static DEFINE_SPINLOCK(k_lock);
-static int k_mode_stop;
 
 #define K_WAIT_TIME	(2 * HZ / 100)
 
@@ -55,6 +54,7 @@ static int k_mode_stop;
 static int init_usb(struct usbwm_dev *udev);
 static void release_usb(struct usbwm_dev *udev);
 
+static struct task_struct *kthread; 
 /*#define DEBUG */
 #ifdef DEBUG
 static void hexdump(char *title, u8 *data, int len)
@@ -720,7 +720,7 @@ static int k_mode_thread(void *arg)
 
 	daemonize("k_mode_wimax");
 
-	while (!k_mode_stop) {
+	while (!kthread_should_stop()) {
 
 		spin_lock_irqsave(&k_lock, flags2);
 		while (!list_empty(&k_list)) {
@@ -781,7 +781,11 @@ static struct usb_driver gdm_usb_driver = {
 static int __init usb_gdm_wimax_init(void)
 {
 #ifdef CONFIG_WIMAX_GDM72XX_K_MODE
-	kthread_run(k_mode_thread, NULL, "WiMax_thread");
+	kthread = kthread_run(k_mode_thread, NULL, "WiMax_thread");
+	if (IS_ERR(kthread)) {
+		printk(KERN_ERR "%s: can't create kernel thread\n", __func__);
+		return PTR_ERR(kthread);
+	}
 #endif /* CONFIG_WIMAX_GDM72XX_K_MODE */
 	return usb_register(&gdm_usb_driver);
 }
@@ -789,7 +793,8 @@ static int __init usb_gdm_wimax_init(void)
 static void __exit usb_gdm_wimax_exit(void)
 {
 #ifdef CONFIG_WIMAX_GDM72XX_K_MODE
-	k_mode_stop = 1;
+	if (kthread)
+		kthread_stop(kthread);
 	wake_up(&k_wait);
 #endif
 	usb_deregister(&gdm_usb_driver);
-- 
1.7.9.5

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