Re: [PATCH] tty: fix tty->ldisc leak on ENODEV from driver install

From: Julian Anastasov
Date: Wed Mar 23 2011 - 04:44:41 EST



Hello,

On Wed, 23 Mar 2011, Jiri Slaby wrote:

--- linux-2.6.38/drivers/tty/tty_io.c
+++ linux-2.6.38/drivers/tty/tty_io.c
@@ -188,6 +188,7 @@ void free_tty_struct(struct tty_struct *
put_device(tty->dev);
kfree(tty->write_buf);
tty_buffer_free_all(tty);
+ kfree(tty->ldisc);

We should not mess up with ldisc here. We should call something like
tty_ldisc_deinit from tty_init_dev on fail path. The deinit should drop
the reference (call put_ldisc). Or maybe even deinitialize_tty_struct ->
tty_ldisc_deinit -> put_ldisc).

Note that your way you do not drop the module refcount of ld ops.

Right, that is what I found before going to sleep.
From the visible functions I see that currently only
tty_ldisc_deref does exactly what we need. But I suspect
it should be used for other purposes. I assume the authors
have a better idea what to do here. Let me know if I need
to test a better patch.

kfree(tty);
}

regards,
--
js
suse labs

Regards

--
Julian Anastasov <ja@xxxxxx>
--
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/