svn commit: r272594 - stable/8/sys/dev/usb

Hans Petter Selasky hselasky at FreeBSD.org
Mon Oct 6 06:08:30 UTC 2014


Author: hselasky
Date: Mon Oct  6 06:08:29 2014
New Revision: 272594
URL: https://svnweb.freebsd.org/changeset/base/272594

Log:
  MFC r272480:
  When we fail to get a USB reference we should just return, because
  there are no more references held.

Modified:
  stable/8/sys/dev/usb/usb_dev.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/usb/   (props changed)

Modified: stable/8/sys/dev/usb/usb_dev.c
==============================================================================
--- stable/8/sys/dev/usb/usb_dev.c	Mon Oct  6 06:07:02 2014	(r272593)
+++ stable/8/sys/dev/usb/usb_dev.c	Mon Oct  6 06:08:29 2014	(r272594)
@@ -293,6 +293,10 @@ error:
 	}
 	mtx_unlock(&usb_ref_lock);
 	DPRINTFN(2, "fail\n");
+
+	/* clear all refs */
+	memset(crd, 0, sizeof(*crd));
+
 	return (USB_ERR_INVAL);
 }
 
@@ -1079,8 +1083,8 @@ usb_ioctl(struct cdev *dev, u_long cmd, 
 		goto done;
 
 	if (usb_usb_ref_device(cpd, &refs)) {
-		err = ENXIO;
-		goto done;
+		/* we lost the reference */
+		return (ENXIO);
 	}
 
 	err = (f->methods->f_ioctl_post) (f, cmd, addr, fflags);
@@ -1103,9 +1107,8 @@ usb_ioctl(struct cdev *dev, u_long cmd, 
 
 		while (usb_ref_device(cpd, &refs, 1 /* need uref */)) {
 			if (usb_ref_device(cpd, &refs, 0)) {
-				/* device no longer exits */
-				err = ENXIO;
-				goto done;
+				/* device no longer exists */
+				return (ENXIO);
 			}
 			usb_unref_device(cpd, &refs);
 			usb_pause_mtx(NULL, hz / 128);
@@ -1241,9 +1244,9 @@ usb_read(struct cdev *dev, struct uio *u
 		return (err);
 
 	err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
-	if (err) {
+	if (err)
 		return (ENXIO);
-	}
+
 	fflags = cpd->fflags;
 
 	f = refs.rxfifo;
@@ -1367,9 +1370,9 @@ usb_write(struct cdev *dev, struct uio *
 		return (err);
 
 	err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
-	if (err) {
+	if (err)
 		return (ENXIO);
-	}
+
 	fflags = cpd->fflags;
 
 	f = refs.txfifo;


More information about the svn-src-stable-8 mailing list