Re: [PATCH 1/2] Introduce tty_unregister_ldisc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2005-05-31 at 17:28 -0500, Paul Fulghum wrote:
> An unmodified ldisc driver (externally maintained) will continue to call
> tty_register_ldisc with NULL, but the new behavior will be to set the
> ldisc pointer to NULL but have LDISC_FLAG_DEFINED set.

I was partially wrong.
After Alexey's patch, a NULL new_ldisc is accessed 
(not assigned) causing an oops. This is still not
good behavior.

As for the refcount bug, this patch should fix it.
Comments?

--
Paul Fulghum
[email protected]

--- linux-2.6.11/drivers/char/tty_io.c	2005-03-02 01:38:10.000000000 -0600
+++ b/drivers/char/tty_io.c	2005-05-31 22:10:41.000000000 -0500
@@ -262,16 +262,16 @@ int tty_register_ldisc(int disc, struct 
 		return -EINVAL;
 	
 	spin_lock_irqsave(&tty_ldisc_lock, flags);
-	if (new_ldisc) {
+	if ((tty_ldiscs[disc].flags & LDISC_FLAG_DEFINED) &&
+	    tty_ldiscs[disc].refcount)
+		ret = -EBUSY;
+	else if (new_ldisc) {
 		tty_ldiscs[disc] = *new_ldisc;
 		tty_ldiscs[disc].num = disc;
 		tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
 		tty_ldiscs[disc].refcount = 0;
 	} else {
-		if(tty_ldiscs[disc].refcount)
-			ret = -EBUSY;
-		else
-			tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
+		tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
 	}
 	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
 	


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux