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

From: Paul Fulghum
Date: Wed Jun 01 2005 - 08:54:22 EST


The following patch would be more appropriate than
my last suggestion for the case of trying to register
a ldisc driver to an occupied slot.

It does not make sense to allow an existing
registered driver to be overwritten, even
if the refcount is zero.

This *should* not happen with unique ldisc numbers,
but it seems like a reasonable check. Even if
Alexey's patch is applied, this would be a
reasonable check to integrate.

--
Paul Fulghum
paulkf@xxxxxxxxxxxxx

--- linux-2.6.11/drivers/char/tty_io.c 2005-03-02 01:38:10.000000000 -0600
+++ b/drivers/char/tty_io.c 2005-06-01 08:34:05.000000000 -0500
@@ -263,10 +263,14 @@ int tty_register_ldisc(int disc, struct

spin_lock_irqsave(&tty_ldisc_lock, flags);
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;
+ if (tty_ldiscs[disc].flags & LDISC_FLAG_DEFINED)
+ ret = -EBUSY;
+ else {
+ 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;


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