Skip to contentSkip to conversation

USB: atm/cxacru, fix lock imbalance

PATCH New Jiri Slaby 1 participant 5 messages Mar 11, 2009

Subsystems (3)
lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/5 USB: atm/cxacru, fix lock imbalance

We do not hold mutex in one place in cxacru_cm, but unlock it on fail path. Fix this.

---
 drivers/usb/atm/cxacru.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/atm/cxacru.c +2 -1
index 5ed4ae0..6789089 100644
@@ -485,7 +485,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
 			usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n",
 				wbuflen, rbuflen);
 		ret = -ENOMEM;
-		goto fail;
+		goto err;
 	}
 
 	mutex_lock(&instance->cm_serialize);
@@ -565,6 +565,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
 	dbg("cm %#x", cm);
 fail:
 	mutex_unlock(&instance->cm_serialize);
+err:
 	return ret;
 }
 
Signature · 2 lines
1.6.2
caught by stanse
author
#1 lore raw

PATCH 2/5 USB: image/mdc800, fix lock imbalance

There is an omitted unlock in mdc800_usb_probe's fail path. Add it.

Cc Henning Zabel <[email protected]>
---
 drivers/usb/image/mdc800.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/usb/image/mdc800.c +1 -0
index efc075c..eca355d 100644
@@ -499,6 +499,7 @@ static int mdc800_usb_probe (struct usb_interface *intf,
 	retval = usb_register_dev(intf, &mdc800_class);
 	if (retval) {
 		dev_err(&intf->dev, "Not able to get a minor for this device.\n");
+		mutex_unlock(&mdc800->io_lock);
 		return -ENODEV;
 	}
 
Signature · 2 lines
1.6.2
caught by stanse
author
#2 lore raw

PATCH 3/5 USB: misc/adutux, fix lock imbalance

In reply to Jiri Slaby

Don't unlock adutux_mutex when not held.

---
 drivers/usb/misc/adutux.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/misc/adutux.c +3 -3
index 7b6922e..2035265 100644
@@ -376,7 +376,7 @@ static int adu_release(struct inode *inode, struct file *file)
 	if (dev->open_count <= 0) {
 		dbg(1," %s : device not opened", __func__);
 		retval = -ENODEV;
-		goto exit;
+		goto unlock;
 	}
 
 	adu_release_internal(dev);
@@ -385,9 +385,9 @@ static int adu_release(struct inode *inode, struct file *file)
 		if (!dev->open_count)	/* ... and we're the last user */
 			adu_delete(dev);
 	}
-
-exit:
+unlock:
 	mutex_unlock(&adutux_mutex);
+exit:
 	dbg(2," %s : leave, return value %d", __func__, retval);
 	return retval;
 }
Signature · 2 lines
1.6.2
caught by stanse
author
#3 lore raw

PATCH 4/5 USB: misc/vstusb, fix lock imbalance

In reply to Jiri Slaby

Make sure we don't leak locked vstdev->lock in vstusb_write. Unlock properly on one fail path.

---
 drivers/usb/misc/vstusb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/usb/misc/vstusb.c +1 -0
index 63dff9b..f26ea8d 100644
@@ -401,6 +401,7 @@ static ssize_t vstusb_write(struct file *file, const char __user *buffer,
 	}
 
 	if (copy_from_user(buf, buffer, count)) {
+		mutex_unlock(&vstdev->lock);
 		dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__);
 		retval = -EFAULT;
 		goto exit;
Signature · 2 lines
1.6.2
caught by stanse
author
#4 lore raw

PATCH 5/5 USB: wusbcore/wa-xfer, fix lock imbalance

In reply to Jiri Slaby

Fix locking on one wa_urb_enqueue_b's fail path. There was omitted unlock.

Cc Inaky Perez-Gonzalez <[email protected]>
---
 drivers/usb/wusbcore/wa-xfer.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/usb/wusbcore/wa-xfer.c +3 -1
index 238a96a..613a5fc 100644
@@ -921,8 +921,10 @@ static void wa_urb_enqueue_b(struct wa_xfer *xfer)
 	result = -ENODEV;
 	/* FIXME: segmentation broken -- kills DWA */
 	mutex_lock(&wusbhc->mutex);		/* get a WUSB dev */
-	if (urb->dev == NULL)
+	if (urb->dev == NULL) {
+		mutex_unlock(&wusbhc->mutex);
 		goto error_dev_gone;
+	}
 	wusb_dev = __wusb_dev_get_by_usb_dev(wusbhc, urb->dev);
 	if (wusb_dev == NULL) {
 		mutex_unlock(&wusbhc->mutex);
Signature · 2 lines
1.6.2
caught by stanse