aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-imx-2.6.35.3/003_Sanitise_ipu_interrupt_return_value.patch
blob: c19995911cf8724935aae635d4ae7b62ffb14b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
commit 7237ebd59bf1cd8bcc9508ec4bc5674dc7cc6c58
Author: Phil Endecott <git@chezphil.org>
Date:   Tue Nov 1 18:16:56 2011 +0000

    Sanitise ipu interrupt return value, and loop waiting for interrupt

diff --git a/drivers/mxc/ipu3/ipu_device.c b/drivers/mxc/ipu3/ipu_device.c
index 1955f09..d66b8f8 100644
--- a/drivers/mxc/ipu3/ipu_device.c
+++ b/drivers/mxc/ipu3/ipu_device.c
@@ -311,7 +311,7 @@ static int mxc_ipu_ioctl(struct inode *inode, struct file *file,
 		structure and pass the pointer in arg */
 		{
 			ipu_event_info info;
-			int r = -1;
+			int r;
 
 			if (copy_from_user
 					(&info, (ipu_event_info *) arg,
@@ -319,7 +319,7 @@ static int mxc_ipu_ioctl(struct inode *inode, struct file *file,
 				return -EFAULT;
 
 			r = get_events(&info);
-			if (r == -1) {
+			while (r == -1) {
 				if ((file->f_flags & O_NONBLOCK) &&
 					(irq_info[info.irq].irq_pending == 0))
 					return -EAGAIN;
@@ -328,13 +328,15 @@ static int mxc_ipu_ioctl(struct inode *inode, struct file *file,
 					return -ERESTARTSYS;
 				}
 				r = get_events(&info);
+				if (r == -1) {
+					/* Shouldn't happen? */
+					printk(KERN_ERR "no events after waiting\n");
+				}
 			}
-			ret = -1;
-			if (r == 0) {
-				if (!copy_to_user((ipu_event_info *) arg,
-					&info, sizeof(ipu_event_info)))
-					ret = 0;
-			}
+			if (copy_to_user((ipu_event_info *) arg,
+				&info, sizeof(ipu_event_info)))
+				return -EFAULT;
+			ret = 0;
 		}
 		break;
 	case IPU_ALOC_MEM: