netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/02] hso patch to fix a -EIO from opening a hso serial device
@ 2009-01-14 11:22 Denis Joseph Barrow
       [not found] ` <496DCAF7.9080906-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Joseph Barrow @ 2009-01-14 11:22 UTC (permalink / raw)
  To: Linux USB kernel mailing list, Linux netdev Mailing list,
	Linux Serial

[-- Attachment #1: Type: text/plain, Size: 1555 bytes --]

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

I'm about 80% sure this patch is correct
but it needs Alan Cox'es blessing as it modifies code he added.

This patch fixes -EIO caused when serial port opened more than once.
Signed-off-by: Denis Joseph Barrow <D.Barow-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
---
Index: linux-2.6/drivers/net/usb/hso.c
===================================================================
--- linux-2.6.orig/drivers/net/usb/hso.c	2009-01-14 11:51:26.000000000 +0100
+++ linux-2.6/drivers/net/usb/hso.c	2009-01-14 11:57:59.000000000 +0100
@@ -1354,13 +1354,14 @@
 	/* do the actual close */
 	serial->open_count--;
 	kref_put(&serial->parent->ref, hso_serial_ref_free);
+	if (serial->tty == tty)
+		tty_kref_put(tty);
 	if (serial->open_count <= 0) {
 		serial->open_count = 0;
 		spin_lock_irq(&serial->serial_lock);
 		if (serial->tty == tty) {
 			serial->tty->driver_data = NULL;
 			serial->tty = NULL;
-			tty_kref_put(tty);
 		}
 		spin_unlock_irq(&serial->serial_lock);
 		if (!usb_gone)
@@ -1368,7 +1369,6 @@
 		tasklet_kill(&serial->unthrottle_tasklet);
 		cancel_work_sync(&serial->retry_unthrottle_workqueue);
 	}
-
 	if (!usb_gone)
 		usb_autopm_put_interface(serial->parent->interface);
 

-- 
best regards,
D.J. Barrow

Linux Kernel Developer
Option NV, Gaston Geenslaan 14, 3001 Leuven, Belgium
 
T: +32 16 311 621
F: +32 16 207 164
d.barow-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org
www.option.com

Disclaimer:
http://www.option.com/company/disclaimer.shtml

[-- Attachment #2: hso_open_eio_fix.patch --]
[-- Type: text/x-diff, Size: 1000 bytes --]

This patch fixes -EIO caused when serial port opened more than once.
Signed-off-by: Denis Joseph Barrow <D.Barow-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
---
Index: linux-2.6/drivers/net/usb/hso.c
===================================================================
--- linux-2.6.orig/drivers/net/usb/hso.c	2009-01-14 11:51:26.000000000 +0100
+++ linux-2.6/drivers/net/usb/hso.c	2009-01-14 11:57:59.000000000 +0100
@@ -1354,13 +1354,14 @@
 	/* do the actual close */
 	serial->open_count--;
 	kref_put(&serial->parent->ref, hso_serial_ref_free);
+	if (serial->tty == tty)
+		tty_kref_put(tty);
 	if (serial->open_count <= 0) {
 		serial->open_count = 0;
 		spin_lock_irq(&serial->serial_lock);
 		if (serial->tty == tty) {
 			serial->tty->driver_data = NULL;
 			serial->tty = NULL;
-			tty_kref_put(tty);
 		}
 		spin_unlock_irq(&serial->serial_lock);
 		if (!usb_gone)
@@ -1368,7 +1369,6 @@
 		tasklet_kill(&serial->unthrottle_tasklet);
 		cancel_work_sync(&serial->retry_unthrottle_workqueue);
 	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 01/02] hso patch to fix a -EIO from opening a hso serial device
       [not found] ` <496DCAF7.9080906-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
@ 2009-01-14 11:38   ` Alan Cox
       [not found]     ` <20090114113828.7b9f59ca-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
  2009-01-15  5:14     ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Cox @ 2009-01-14 11:38 UTC (permalink / raw)
  To: Denis Joseph Barrow
  Cc: Linux USB kernel mailing list, Linux netdev Mailing list,
	Linux Serial

On Wed, 14 Jan 2009 12:22:31 +0100
Denis Joseph Barrow <D.Barow-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>


---

 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);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 01/02] hso patch to fix a -EIO from opening a hso serial device
       [not found]     ` <20090114113828.7b9f59ca-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
@ 2009-01-14 12:40       ` Denis Joseph Barrow
  2009-01-14 13:04         ` Alan Cox
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Joseph Barrow @ 2009-01-14 12:40 UTC (permalink / raw)
  To: Alan Cox
  Cc: Linux USB kernel mailing list, Linux netdev Mailing list,
	Linux Serial

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-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> 
> 
> ---
> 
>  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);
>  


-- 
best regards,
D.J. Barrow

Linux Kernel Developer
Option NV, Gaston Geenslaan 14, 3001 Leuven, Belgium
 
T: +32 16 311 621
F: +32 16 207 164
d.barow-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org
www.option.com

Disclaimer:
http://www.option.com/company/disclaimer.shtml
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 01/02] hso patch to fix a -EIO from opening a hso serial device
  2009-01-14 12:40       ` Denis Joseph Barrow
@ 2009-01-14 13:04         ` Alan Cox
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Cox @ 2009-01-14 13:04 UTC (permalink / raw)
  To: Denis Joseph Barrow
  Cc: Linux USB kernel mailing list, Linux netdev Mailing list,
	Linux Serial

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 01/02] hso patch to fix a -EIO from opening a hso serial device
  2009-01-14 11:38   ` Alan Cox
       [not found]     ` <20090114113828.7b9f59ca-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
@ 2009-01-15  5:14     ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2009-01-15  5:14 UTC (permalink / raw)
  To: alan; +Cc: D.Barow, linux-usb, netdev, linux-serial

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-01-15  5:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-14 11:22 [PATCH 01/02] hso patch to fix a -EIO from opening a hso serial device Denis Joseph Barrow
     [not found] ` <496DCAF7.9080906-x9gZzRpC1QbQT0dZR+AlfA@public.gmane.org>
2009-01-14 11:38   ` Alan Cox
     [not found]     ` <20090114113828.7b9f59ca-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2009-01-14 12:40       ` Denis Joseph Barrow
2009-01-14 13:04         ` Alan Cox
2009-01-15  5:14     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).