mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
To: Alan Cox <alan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>
Subject: Re: [PATCH] vt: avoid BUG_ON in con_shutdown when con_open returns with error
Date: Thu, 31 Mar 2011 10:37:26 -0300	[thread overview]
Message-ID: <20110331133725.GA2040@herton-IdeaPad-Y430> (raw)
In-Reply-To: <20110331105811.5d989e86@bob.linux.org.uk>

On Thu, Mar 31, 2011 at 10:58:11AM +0100, Alan Cox wrote:
> O
> > +static inline void con_ops_set_shutdown(void);
> >  static int con_open(struct tty_struct *, struct file *);
> >  static void vc_init(struct vc_data *vc, unsigned int rows,
> >  		    unsigned int cols, int do_clear);
> > @@ -2806,6 +2807,14 @@ static int con_open(struct tty_struct *tty,
> > struct file *filp) tty->driver_data = vc;
> >  			vc->port.tty = tty;
> >  
> > +			/* We must set shutdown only here, otherwise
> > +			 * we returned from con_open with error,
> > which
> > +			 * will make tty core call tty_release, that
> > +			 * in its call path makes con_shutdown being
> > +			 * called without tty->driver_data being set,
> > +			 * triggering the BUG_ON there */
> > +			con_ops_set_shutdown();
> 
> No we cannot go around patching the tty_operations - they are not
> locked for one.

Indeed, I feel in those "wearing a brown paper bag" moments now...

> 
> Probably this is one case where making con_shutdown() check is the
> right answer.
> 

I still wonder though if really the BUG_ON is ok, or I still didn't got
that code right. Even if it returns -ERESTARTSYS we will hit that
BUG_ON, if vc->port.tty != tty no? Or that is what the BUG_ON is trying
to catch?

While looking I noted a minor thing, in tty_open we don't need to check
retval again in one place, as !retval is always true, because we return
earlier (in retval = tty_add_file ...):

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 936a4ea..349fa67 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1902,12 +1902,10 @@ got_driver:
 #ifdef TTY_DEBUG_HANGUP
 	printk(KERN_DEBUG "opening %s...", tty->name);
 #endif
-	if (!retval) {
-		if (tty->ops->open)
-			retval = tty->ops->open(tty, filp);
-		else
-			retval = -ENODEV;
-	}
+	if (tty->ops->open)
+		retval = tty->ops->open(tty, filp);
+	else
+		retval = -ENODEV;
 	filp->f_flags = saved_flags;
 
 	if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) &&

-- 
[]'s
Herton

  reply	other threads:[~2011-03-31 13:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-30 22:29 Herton Ronaldo Krzesinski
2011-03-31  9:58 ` Alan Cox
2011-03-31 13:37   ` Herton Ronaldo Krzesinski [this message]
2011-03-31 14:52     ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110331133725.GA2040@herton-IdeaPad-Y430 \
    --to=herton.krzesinski@canonical.com \
    --cc=alan@linux.intel.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®