[alsa-devel] [PATCH - asihpi 2/3] Include adapter buffer alloc inside adapter mutex

linux at audioscience.com linux at audioscience.com
Thu Aug 21 03:29:55 CEST 2008


From: Eliot Blennerhassett <eliot at zaphod.(none)>


Signed-off-by: Eliot Blennerhassett <eblennerhassett at audioscience.com>

diff --git a/pci/asihpi/hpioctl.c b/pci/asihpi/hpioctl.c
index 27a273a..8222178 100644
--- a/pci/asihpi/hpioctl.c
+++ b/pci/asihpi/hpioctl.c
@@ -159,6 +159,9 @@ long asihpi_hpi_ioctl(
 			return 0;
 		}
 
+		if (mutex_lock_interruptible(&adapters[nAdapter].mutex))
+			return -EINTR;
+
 		/* Dig out any pointers embedded in the message.  */
 		switch (hm.wFunction) {
 		case HPI_SUBSYS_CREATE_ADAPTER:
@@ -216,9 +219,6 @@ long asihpi_hpi_ioctl(
 			break;
 		}
 
-		if (mutex_lock_interruptible(&adapters[nAdapter].mutex))
-			return -EINTR;
-
 		if (wrflag == 0) {
 			uncopied_bytes =
 				copy_from_user(pa->pBuffer, ptr, size);
@@ -246,11 +246,10 @@ long asihpi_hpi_ioctl(
 	/* on return response size must be set */
 	if (!hr.wSize)
 		return -EFAULT;
-
-	/* Copy the response back to user space.  */
 	uncopied_bytes = copy_to_user(phr, &hr, sizeof(hr));
 	if (uncopied_bytes)
 		return -EFAULT;
+
 	return 0;
 }
 
-- 
1.5.4.3



More information about the Alsa-devel mailing list