Skip to contentSkip to conversation

drivers/tty: Fix missed unlocks for tty_release

PATCH In review Li, Zhen-Hua 1 participant 2 messages Dec 9, 2013 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/tty: Fix missed unlocks for tty_release

In function tty_release, there are two unlock not called while breaking from a while. This may cause problems.
This patch fixed this problem , adding the two unlocks before break is called.

---
 drivers/tty/tty_io.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/tty_io.c +4 -2
index c74a00a..d41b0da 100644
@@ -1777,9 +1777,11 @@ int tty_release(struct inode *inode, struct file *filp)
 				do_sleep++;
 			}
 		}
-		if (!do_sleep)
+		if (!do_sleep) {
+			tty_unlock_pair(tty, o_tty);
+			mutex_unlock(&tty_mutex);
 			break;
-
+		}
 		printk(KERN_WARNING "%s: %s: read/write wait queue active!\n",
 				__func__, tty_name(tty, buf));
 		tty_unlock_pair(tty, o_tty);
Signature · 1 line
1.8.4.3
#1 lore raw

Hi,

I found it was incorrect. So please IGNORE this patch. Sorry for that.

Quoted 29 lines · Zhen-Hua

In function tty_release, there are two unlock not called while breaking from a while. This may cause problems.
This patch fixed this problem , adding the two unlocks before break is called.

---
  drivers/tty/tty_io.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/tty_io.c +4 -2
index c74a00a..d41b0da 100644
@@ -1777,9 +1777,11 @@ int tty_release(struct inode *inode, struct file *filp)
  				do_sleep++;
  			}
  		}
-		if (!do_sleep)
+		if (!do_sleep) {
+			tty_unlock_pair(tty, o_tty);
+			mutex_unlock(&tty_mutex);
  			break;
-
+		}
  		printk(KERN_WARNING "%s: %s: read/write wait queue active!\n",
  				__func__, tty_name(tty, buf));
  		tty_unlock_pair(tty, o_tty);