Subject: Re: [RFC] updated Patch to option HSO driver to the kernel

From: Paulius Zaleckas <[email-masked]>
Date: Mon, 28 Apr 2008 13:53:17 +0300

Incremental patch.
- fix bug with freeing locked mutex:

 > =========================
 > [ BUG: held lock freed! ]
 > -------------------------
 > modprobe/3829 is freeing memory ffff81002acb5948-ffff81002acb5a07, with
 > a lock still held there!
 >  (&mux->shared_int_lock){--..}, at: [<ffffffff88303234>]
 > hso_serial_ref_free+0x7a/0xce [hso]
 > 1 lock held by modprobe/3829:
 >  #0:  (&mux->shared_int_lock){--..}, at: [<ffffffff88303234>]
 > hso_serial_ref_free+0x7a/0xce [hso]
--- linux-2.6-hso-my/drivers/net/usb/hso.c.orig	2008-04-25 16:13:41.000000000 +0300
+++ linux-2.6-hso-my/drivers/net/usb/hso.c	2008-04-28 12:34:23.000000000 +0300
@@ -2210,7 +2210,8 @@ static void hso_free_serial_device(struc
 		mutex_lock(&serial->shared_int->shared_int_lock);
 		if (--serial->shared_int->ref_count == 0)
 			hso_free_shared_int(serial->shared_int);
-		mutex_unlock(&serial->shared_int->shared_int_lock);
+		else
+			mutex_unlock(&serial->shared_int->shared_int_lock);
 	}
 	kfree(serial);
 	hso_free_device(hso_dev);
@@ -2360,6 +2361,7 @@ static void hso_free_shared_int(struct h
 {
 	usb_free_urb(mux->shared_intr_urb);
 	kfree(mux->shared_intr_buf);
+	mutex_unlock(&mux->shared_int_lock);
 	kfree(mux);
 }