Hello,
I just added a small patch to ToUserDevice. The problem occurs when a script fails, because some element is not configured correctly. Then, click-install bails and calls "cleanup" of ToUserDevice. However, "configure" of ToUserDevice was never called, resulting in a soft lockup, as an uninitialized spin_lock is acquired. I have made a small change in cleanup which will detect this situation and avoid the soft lockup.

Roman
diff --git a/elements/linuxmodule/touserdevice.cc b/elements/linuxmodule/touserdevice.cc
index fa9db93..e27974d 100644
--- a/elements/linuxmodule/touserdevice.cc
+++ b/elements/linuxmodule/touserdevice.cc
@@ -115,7 +115,7 @@ int ToUserDevice::dev_open(struct inode *inode, struct file *filp)
     return 0;
 }
 
-// close function - called when the "file" /dev/toclikc is closed in userspace  
+// close function - called when the "file" /dev/toclick is closed in userspace  
 int ToUserDevice::dev_release(struct inode *inode, struct file *filp)
 {
     ToUserDevice *elem = GETELEM(filp);
@@ -137,7 +137,7 @@ int ToUserDevice::dev_ioctl(struct inode *inode, struct file *filp,
 	return ((uintptr_t) filp->private_data) & 1;
     else if (command == CLICK_IOC_TOUSERDEVICE_SET_MULTI) {
 	if ((int) address != 0 && (int) address != 1)
-	    return -EINVAL;
+            return -EINVAL;
 	filp->private_data = (void *) ((uintptr_t) elem | (int) address);
 	return 0;
     } else
@@ -311,12 +311,11 @@ void ToUserDevice::cleanup(CleanupStage)
 {
     //click_chatter("cleanup...");
 
-    spin_lock(&_lock); // LOCK
-    DEV_NUM--;
-    _exit = true; // signal for exit
-    spin_unlock(&_lock); // UNLOCK
-
     if (_q) {
+        spin_lock(&_lock); // LOCK
+        DEV_NUM--;
+        _exit = true; // signal for exit
+        spin_unlock(&_lock); // UNLOCK
         //click_chatter(" Start ");
         wake_up_interruptible(&_proc_queue);
 	while (waitqueue_active(&_proc_queue))
@@ -336,7 +335,9 @@ void ToUserDevice::cleanup(CleanupStage)
 	}
         click_lfree((char*)_q, _capacity * sizeof(Packet *));
     }
-    click_chatter("cleanup Done. ");
+    else
+        click_chatter("Cleanup: ToUserDevice was never configured\n");
+    //click_chatter("cleanup Done. ");
 }
 
 bool ToUserDevice::process(Packet *p)
_______________________________________________
click mailing list
click@amsterdam.lcs.mit.edu
https://amsterdam.lcs.mit.edu/mailman/listinfo/click

Reply via email to