Skip to contentSkip to conversation

Fix refcount leak in tty_port.c

PATCH Gianluca Anzolin 2 participants 2 messages Jul 12, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20130709083535.GA30227

#1 lore raw

Hello,

I'm sorry to bother you again, I'm just pinging to see if you received the patch or if it got lost in the noise. It fixes a regression introduced in git commit aa27a094e2c2e

I have another patch for rfcomm tty waiting for this fix to get applied.

Thank you,

Gianluca

Quoted 35 lines · Gianluca Anzolin

Hello,

In linux 3.10 in the file drivers/tty/tty_port.c the function tty_port_tty_hangup may leak a tty reference:

        struct tty_struct *tty = tty_port_tty_get(port);

        if (tty && (!check_clocal || !C_CLOCAL(tty))) {
                tty_hangup(tty);
                tty_kref_put(tty);
        }

If tty != NULL and the second condition is false we never call tty_kref_put and the reference is leaked.

Fix by nesting two if statements.

drivers/tty/tty_port.c +3 -2
index 121aeb9..2198f7d 100644
@@ -256,8 +256,9 @@ void tty_port_tty_hangup(struct tty_port *port, bool check_clocal)
 {
 	struct tty_struct *tty = tty_port_tty_get(port);
 
-	if (tty && (!check_clocal || !C_CLOCAL(tty))) {
-		tty_hangup(tty);
+	if (tty) {
+		if (!check_clocal || !C_CLOCAL(tty))
+			tty_hangup(tty);
 		tty_kref_put(tty);
 	}
 }
#2 lore raw
Quoted 7 lines · Gianluca Anzolin

Hello,

I'm sorry to bother you again, I'm just pinging to see if you received the patch or if it got lost in the noise. It fixes a regression introduced in git commit aa27a094e2c2e

I have another patch for rfcomm tty waiting for this fix to get applied.

I have it, just waiting for 3.11-rc1 to come out before dealing with any new patches.

thanks,

greg k-h