public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty: replace mutex_lock() with tty_write_lock()
@ 2013-11-21 19:12 Andreas Platschek
  2013-11-22  8:09 ` walter harms
  2013-11-22  8:25 ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Andreas Platschek @ 2013-11-21 19:12 UTC (permalink / raw)
  To: gregkh; +Cc: jslaby, linux-kernel, kernel-janitors, 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

Signed-off-by: Andreas Platschek <andi.platschek@gmail.com>
---
 drivers/tty/tty_io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 3a1a01a..13dca92 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] tty: replace mutex_lock() with tty_write_lock()
  2013-11-21 19:12 [PATCH] tty: replace mutex_lock() with tty_write_lock() Andreas Platschek
@ 2013-11-22  8:09 ` walter harms
  2013-11-22  8:22   ` Andreas Platschek
  2013-11-22  8:29   ` Dan Carpenter
  2013-11-22  8:25 ` Dan Carpenter
  1 sibling, 2 replies; 5+ messages in thread
From: walter harms @ 2013-11-22  8:09 UTC (permalink / raw)
  To: Andreas Platschek; +Cc: gregkh, jslaby, linux-kernel, kernel-janitors



Am 21.11.2013 20:12, schrieb 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
> 
> Signed-off-by: Andreas Platschek <andi.platschek@gmail.com>
> ---
>  drivers/tty/tty_io.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 3a1a01a..13dca92 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tty: replace mutex_lock() with tty_write_lock()
  2013-11-22  8:09 ` walter harms
@ 2013-11-22  8:22   ` Andreas Platschek
  2013-11-22  8:29   ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Platschek @ 2013-11-22  8:22 UTC (permalink / raw)
  To: wharms; +Cc: gregkh, jslaby, linux-kernel, kernel-janitors

Hi,

On 11/22/2013 09:09 AM, walter harms wrote:
>
> Am 21.11.2013 20:12, schrieb 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
>>
>> Signed-off-by: Andreas Platschek <andi.platschek@gmail.com>
>> ---
>>  drivers/tty/tty_io.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
>> index 3a1a01a..13dca92 100644
>> --- a/drivers/tty/tty_io.c
>> +++ b/drivers/tty/tty_io.c
>> @@ -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
>
> re,
>  wh


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tty: replace mutex_lock() with tty_write_lock()
  2013-11-21 19:12 [PATCH] tty: replace mutex_lock() with tty_write_lock() Andreas Platschek
  2013-11-22  8:09 ` walter harms
@ 2013-11-22  8:25 ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2013-11-22  8:25 UTC (permalink / raw)
  To: Andreas Platschek; +Cc: gregkh, jslaby, linux-kernel, kernel-janitors

On Thu, Nov 21, 2013 at 08:12:12PM +0100, Andreas Platschek wrote:
> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tty: replace mutex_lock() with tty_write_lock()
  2013-11-22  8:09 ` walter harms
  2013-11-22  8:22   ` Andreas Platschek
@ 2013-11-22  8:29   ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2013-11-22  8:29 UTC (permalink / raw)
  To: walter harms
  Cc: Andreas Platschek, gregkh, jslaby, linux-kernel, kernel-janitors

On Fri, Nov 22, 2013 at 09:09:15AM +0100, walter harms wrote:
> 
> 
> Am 21.11.2013 20:12, schrieb 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
> > 
> > Signed-off-by: Andreas Platschek <andi.platschek@gmail.com>
> > ---
> >  drivers/tty/tty_io.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> > index 3a1a01a..13dca92 100644
> > --- a/drivers/tty/tty_io.c
> > +++ b/drivers/tty/tty_io.c
> > @@ -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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-22  8:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-21 19:12 [PATCH] tty: replace mutex_lock() with tty_write_lock() Andreas Platschek
2013-11-22  8:09 ` walter harms
2013-11-22  8:22   ` Andreas Platschek
2013-11-22  8:29   ` Dan Carpenter
2013-11-22  8:25 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox