From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] tty: Fix leak in ti-usb
Date: Tue, 14 Apr 2009 14:58:11 +0100 [thread overview]
Message-ID: <20090414135741.13935.99227.stgit@t61.ukuu.org.uk> (raw)
In-Reply-To: <20090414135501.13935.13500.stgit@t61.ukuu.org.uk>
If the ti-usb adapter returns an zero data length frame (which happens) then
we leak a kref. Found by Christoph Mair <christoph.mair@gmail.com> who proposed
a patch. The patch here is different as Christoph's patch didn't work
for the case where tty = NULL and data arrived but Christoph did all the
hard work chasing it down.
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
drivers/usb/serial/ti_usb_3410_5052.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 2620bf6..9c4c700 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1215,20 +1215,22 @@ static void ti_bulk_in_callback(struct urb *urb)
}
tty = tty_port_tty_get(&port->port);
- if (tty && urb->actual_length) {
- usb_serial_debug_data(debug, dev, __func__,
- urb->actual_length, urb->transfer_buffer);
-
- if (!tport->tp_is_open)
- dbg("%s - port closed, dropping data", __func__);
- else
- ti_recv(&urb->dev->dev, tty,
+ if (tty) {
+ if (urb->actual_length) {
+ usb_serial_debug_data(debug, dev, __func__,
+ urb->actual_length, urb->transfer_buffer);
+
+ if (!tport->tp_is_open)
+ dbg("%s - port closed, dropping data",
+ __func__);
+ else
+ ti_recv(&urb->dev->dev, tty,
urb->transfer_buffer,
urb->actual_length);
-
- spin_lock(&tport->tp_lock);
- tport->tp_icount.rx += urb->actual_length;
- spin_unlock(&tport->tp_lock);
+ spin_lock(&tport->tp_lock);
+ tport->tp_icount.rx += urb->actual_length;
+ spin_unlock(&tport->tp_lock);
+ }
tty_kref_put(tty);
}
next prev parent reply other threads:[~2009-04-14 12:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-14 13:57 [PATCH 0/4] Small fixes for rc2 Alan Cox
2009-04-14 13:57 ` [PATCH 1/4] cdc-acm: Fix long standing abuse of tty->low_latency Alan Cox
2009-04-14 14:18 ` Oliver Neukum
2009-04-14 13:58 ` Alan Cox [this message]
2009-04-14 13:58 ` [PATCH 3/4] parport: Fix various uses of parport_pc Alan Cox
2009-04-14 13:58 ` [PATCH 4/4] parport_pc: Fix build failure drivers/parport/parport_pc.c for powerpc Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090414135741.13935.99227.stgit@t61.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®