netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patches for hso driver
@ 2009-11-18  7:35 Martin Schiller
  2009-11-18 18:01 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Schiller @ 2009-11-18  7:35 UTC (permalink / raw)
  To: netdev

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

Hi,

I've found some problems in the hso driver for Option HSxPA devices.

The first and most important are 2 memory leaks in the buffer cleanup routines.
Have a look at the "hso-memleak.patch" file to see what I mean.

ATTENTION:
-------------------------------------------------------------------------------------
kmemleak still finds 1 remaining leak, but i can't find it:

unreferenced object 0xce461130 (size 32):
 comm "khubd", pid 1105, jiffies 17464
 backtrace:
   [<c10745b6>] create_object+0xe6/0x210
   [<c10747d7>] kmemleak_alloc+0x27/0x60
   [<c1071b0d>] kmem_cache_alloc+0xcd/0x120
   [<d0ba29a7>] hso_create_net_device+0x207/0x420 [hso]
   [<d0ba30c7>] hso_probe+0x417/0x690 [hso]
   [<d0998103>] usb_probe_interface+0x83/0x170 [usbcore]
   [<c113f9e2>] driver_probe_device+0x62/0x140
   [<c113fb81>] __device_attach+0x41/0x50
   [<c113f098>] bus_for_each_drv+0x48/0x70
   [<c113fc2d>] device_attach+0x6d/0x80
   [<c113eeed>] bus_probe_device+0x1d/0x40
   [<c113da66>] device_add+0x436/0x4f0
   [<d0997654>] usb_set_configuration+0x424/0x5c0 [usbcore]
   [<d099e68e>] generic_probe+0x2e/0xa0 [usbcore]
   [<d09979cf>] usb_probe_device+0x1f/0x30 [usbcore]
   [<c113f9e2>] driver_probe_device+0x62/0x140

Maybe anyone else have an idea for that.
-------------------------------------------------------------------------------------

The second patch "hso-disable_net.patch" stops the useless creation of an serial
ttyHS<x> for the Network Port, when disable_net=1 is set. By that, the order
of the ttyHS<x> is always the same, regardless if disable_net is set or not.

Best Regards,
Martin

[-- Attachment #2: hso-memleak.patch --]
[-- Type: application/octet-stream, Size: 1255 bytes --]

Subject: memory leak in hso driver

This patches fixes 2 memory leaks in the hso driver.
The first problem is, that the tx_buffer of a serial device will never be freed.
The second one is, that hso_net is also freed by free_netdev(). So, the rx urbs
and buffers must be freed before free_netdev().

Signed-off-by: Martin Schiller <mschiller@tdt.de>

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index b862e66..6865f3f 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2312,6 +2312,7 @@ static void hso_serial_common_free(struct hso_serial *serial)
 	/* unlink and free TX URB */
 	usb_free_urb(serial->tx_urb);
 	kfree(serial->tx_data);
+	kfree(serial->tx_buffer);
 }
 
 static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
@@ -2438,7 +2439,6 @@ static void hso_free_net_device(struct hso_device *hso_dev)
 
 	if (hso_net->net) {
 		unregister_netdev(hso_net->net);
-		free_netdev(hso_net->net);
 	}
 
 	/* start freeing */
@@ -2451,6 +2451,10 @@ static void hso_free_net_device(struct hso_device *hso_dev)
 	kfree(hso_net->mux_bulk_tx_buf);
 	hso_net->mux_bulk_tx_buf = NULL;
 
+	if (hso_net->net) {
+		free_netdev(hso_net->net);
+	}
+
 	kfree(hso_dev);
 }
 

[-- Attachment #3: hso-disable_net.patch --]
[-- Type: application/octet-stream, Size: 942 bytes --]

Subject: Fix interface order when disabled_net=1 in hso driver

This patch stops the useless creation of an serial ttyHS<x> for the
Network Port, when disable_net=1 is set. By that, the order of the
ttyHS<x> is always the same, regardless if disable_net is set or not.

Signed-off-by: Martin Schiller <mschiller@tdt.de>

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index a11dfd0..e9210b7 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2993,9 +2993,10 @@ static int hso_probe(struct usb_interface *interface,
 
 	case HSO_INTF_BULK:
 		/* It's a regular bulk interface */
-		if (((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK)
-		    && !disable_net)
+		if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) {
+		    if (!disable_net)
 			hso_dev = hso_create_net_device(interface, port_spec);
+		}
 		else
 			hso_dev =
 			    hso_create_bulk_serial_device(interface, port_spec);

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

* Re: Patches for hso driver
  2009-11-18  7:35 Patches for hso driver Martin Schiller
@ 2009-11-18 18:01 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2009-11-18 18:01 UTC (permalink / raw)
  To: mschiller; +Cc: netdev

From: "Martin Schiller" <mschiller@tdt.de>
Date: Wed, 18 Nov 2009 08:35:30 +0100

> Have a look at the "hso-memleak.patch" file to see what I mean.

Hmmm...

Please make sure this all works properly, considering
the games that hso_kick_transmit() plays wherein it
swaps ->tx_data and ->tx_buffer every packet send.

Also, please submit your patches sperately and numbered
with changelog and signoffs specific to each change as
described in  linux/Documentation/SubmittingPatches 

Thanks.

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

end of thread, other threads:[~2009-11-18 18:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18  7:35 Patches for hso driver Martin Schiller
2009-11-18 18:01 ` 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).