Patchwork [01/02] hso patch to fix a -EIO from opening a hso serial device

login
register
mail settings
Submitter Alan Cox
Date Jan. 14, 2009, 11:38 a.m.
Message ID <20090114113828.7b9f59ca@lxorguk.ukuu.org.uk>
Download mbox | patch
Permalink /patch/18421/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Alan Cox - Jan. 14, 2009, 11:38 a.m.
On Wed, 14 Jan 2009 12:22:31 +0100
Denis Joseph Barrow <D.Barow@option.com> wrote:

> Hi All,
> This is an important patch the linux-2.6.29-rc1 driver with itworks much
> better than it did.

How about this. 

tty: Fix a kref leak in the HSO driver on re-open

From: Alan Cox <alan@redhat.com>


---

 drivers/net/usb/hso.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Denis Joseph Barrow - Jan. 14, 2009, 12:40 p.m.
Hi Alan,
Your fix works too I suspect better than mine & since you've a better idea of what
you are doing with tty layer than I do we'll stick with
your fix.

Do you want me to switch off the low latency stuff in the
driver?

I also need to investigate the tty_kref_put & tty_kref_get
& when it was added to the kernel so I can fix stuff for our
internal driver



Alan Cox wrote:
> On Wed, 14 Jan 2009 12:22:31 +0100
> Denis Joseph Barrow <D.Barow@option.com> wrote:
> 
>> Hi All,
>> This is an important patch the linux-2.6.29-rc1 driver with itworks much
>> better than it did.
> 
> How about this. 
> 
> tty: Fix a kref leak in the HSO driver on re-open
> 
> From: Alan Cox <alan@redhat.com>
> 
> 
> ---
> 
>  drivers/net/usb/hso.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> 
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index c4918b8..9df04dd 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
> @@ -1297,6 +1297,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
>  	/* setup */
>  	spin_lock_irq(&serial->serial_lock);
>  	tty->driver_data = serial;
> +	tty_kref_put(serial->tty);
>  	serial->tty = tty_kref_get(tty);
>  	spin_unlock_irq(&serial->serial_lock);
>
Alan Cox - Jan. 14, 2009, 1:04 p.m.
> Your fix works too I suspect better than mine & since you've a better idea of what
> you are doing with tty layer than I do we'll stick with
> your fix.

Ok. 

> Do you want me to switch off the low latency stuff in the
> driver?

Lets leave it for now - it can get sorted properly when everything is
stable - no rush.

> I also need to investigate the tty_kref_put & tty_kref_get
> & when it was added to the kernel so I can fix stuff for our
> internal driver

About 2.6.27/28 and while it closes some small race conditions on exit
its not essential so probably not worth worrying about for older kernels
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 15, 2009, 5:14 a.m.
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
Date: Wed, 14 Jan 2009 11:38:28 +0000

> On Wed, 14 Jan 2009 12:22:31 +0100
> Denis Joseph Barrow <D.Barow@option.com> wrote:
> 
> > Hi All,
> > This is an important patch the linux-2.6.29-rc1 driver with itworks much
> > better than it did.
> 
> How about this. 
> 
> tty: Fix a kref leak in the HSO driver on re-open
> 
> From: Alan Cox <alan@redhat.com>

Alan, if you could take this and the spinlock fix Danis also posted
(it's around a tty call: http://patchwork.ozlabs.org/patch/18412/), and
get them merged upstream, I'd appreciate it.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index c4918b8..9df04dd 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1297,6 +1297,7 @@  static int hso_serial_open(struct tty_struct *tty, struct file *filp)
 	/* setup */
 	spin_lock_irq(&serial->serial_lock);
 	tty->driver_data = serial;
+	tty_kref_put(serial->tty);
 	serial->tty = tty_kref_get(tty);
 	spin_unlock_irq(&serial->serial_lock);