Re: [PATCH 3/3] vt: Fix refcounting use

From: Richard Kennedy
Date: Wed Feb 17 2010 - 10:39:47 EST


On 17/02/10 13:23, Alan Cox wrote:
We want to properly refcount the vc tty because of the cases where a vc is
disassociated from a tty (eg destroyed). At the moment the code isn't safe
and in fact input even tries to patch up broken pointers as a result!

static void applkey(struct vc_data *vc, int key, char mode)
@@ -497,10 +499,12 @@ static void fn_show_ptregs(struct vc_data *vc)

static void fn_hold(struct vc_data *vc)
{
- struct tty_struct *tty = vc->port.tty;
+ struct tty_struct *tty = tty_port_tty_get(&vc->port);

- if (rep || !tty)
+ if (rep || !tty) {
+ tty_kref_put(tty);
return;
+ }


This is the only bit that immediately stands out..
maybe?
if (rep || !tty) {
if (tty)
tty_kref_put(tty);
return;
}

regards
Richard

--
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/