Skip to contentSkip to conversation

tty: replace mutex_lock() with tty_write_lock()

PATCH In review Andreas Platschek 3 participants 5 messages Nov 21, 2013 – Nov 22, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: replace mutex_lock() with tty_write_lock()

Use tty_write_lock()/tty_write_unlock() consistently.

This takes care of the following sparse warning:
drivers/tty/tty_io.c:1169:17: warning: context imbalance in 'tty_write_message' - unexpected unlock

---
 drivers/tty/tty_io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +1 -1
index 3a1a01a..13dca92 100644
@@ -1165,7 +1165,7 @@ out:
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
 	if (tty) {
-		mutex_lock(&tty->atomic_write_lock);
+		tty_write_lock(tty,0);
 		tty_lock(tty);
 		if (tty->ops->write && !test_bit(TTY_CLOSING, &tty->flags)) {
 			tty_unlock(tty);
Signature · 1 line
1.7.10.4
#1 lore raw

Am 21.11.2013 20:12, schrieb Andreas Platschek:

Quoted 15 lines

Use tty_write_lock()/tty_write_unlock() consistently.

This takes care of the following sparse warning:
drivers/tty/tty_io.c:1169:17: warning: context imbalance in 'tty_write_message' - unexpected unlock

---
 drivers/tty/tty_io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +0 -0
index 3a1a01a..13dca92 100644

drivers/tty/tty_io.c out: · line 1171

Quoted 8 lines
drivers/tty/tty_io.c +1 -1
@@ -1165,7 +1165,7 @@ out:
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
 	if (tty) {
-		mutex_lock(&tty->atomic_write_lock);
+		tty_write_lock(tty,0);
 		tty_lock(tty);
 		if (tty->ops->write && !test_bit(TTY_CLOSING, &tty->flags)) {
 			tty_unlock(tty);

i am not an expert on this but you may need to replace that tty_unlock() with tty_write_unlock().

re,
wh

#2 lore raw

Hi,

Quoted 12 lines · walter harms

Am 21.11.2013 20:12, schrieb Andreas Platschek:

Quoted 10 lines

Use tty_write_lock()/tty_write_unlock() consistently.

This takes care of the following sparse warning:
drivers/tty/tty_io.c:1169:17: warning: context imbalance in 'tty_write_message' - unexpected unlock

---
 drivers/tty/tty_io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

drivers/tty/tty_io.c out: · line 1171

Quoted 13 lines
drivers/tty/tty_io.c +1 -1
index 3a1a01a..13dca92 100644
@@ -1165,7 +1165,7 @@ out:
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
 	if (tty) {
-		mutex_lock(&tty->atomic_write_lock);
+		tty_write_lock(tty,0);
 		tty_lock(tty);
 		if (tty->ops->write && !test_bit(TTY_CLOSING, &tty->flags)) {
 			tty_unlock(tty);

i am not an expert on this but you may need to replace that tty_unlock() with tty_write_unlock()

The tty_unlock() you see in the patch belongs to the tty_lock() right after the tty_write_lock(), the tty_write_unlock() is already in place without my patch.

tty_lock()/tty_unlock() and tty_write_lock()/tty_write_unlock() are operating on different mutexes, both are needed here.

thx!
Andi

Quoted 3 lines

re,
wh

#3 lore raw
In reply to walter harms
Quoted 13 lines · walter harms

Am 21.11.2013 20:12, schrieb Andreas Platschek:

Quoted 10 lines

Use tty_write_lock()/tty_write_unlock() consistently.

This takes care of the following sparse warning:
drivers/tty/tty_io.c:1169:17: warning: context imbalance in 'tty_write_message' - unexpected unlock

---
 drivers/tty/tty_io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

drivers/tty/tty_io.c out: · line 1171

Quoted 13 lines
drivers/tty/tty_io.c +1 -1
index 3a1a01a..13dca92 100644
@@ -1165,7 +1165,7 @@ out:
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
 	if (tty) {
-		mutex_lock(&tty->atomic_write_lock);
+		tty_write_lock(tty,0);
 		tty_lock(tty);
 		if (tty->ops->write && !test_bit(TTY_CLOSING, &tty->flags)) {
 			tty_unlock(tty);

i am not an expert on this but you may need to replace that tty_unlock() with tty_write_unlock().

No. The original code is correct.

regards,
dan carpenter

#4 lore raw
In reply to Andreas Platschek
Quoted 5 lines · Andreas Platschek

Use tty_write_lock()/tty_write_unlock() consistently.

This takes care of the following sparse warning:
drivers/tty/tty_io.c:1169:17: warning: context imbalance in 'tty_write_message' - unexpected unlock

I don't think we can do this. mutex_lock() always succeeds and tty_write_lock() can fail.

I think we just have to live with the error message.

regards,
dan carpenter