patch-2.4.26 linux-2.4.26/drivers/char/drm-4.0/r128_state.c

Next file: linux-2.4.26/drivers/char/q40_keyb.c
Previous file: linux-2.4.26/drivers/char/drm/r128_state.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.25/drivers/char/drm-4.0/r128_state.c linux-2.4.26/drivers/char/drm-4.0/r128_state.c
@@ -938,6 +938,9 @@
 	}
 
 	count = depth->n;
+
+	if (count > 4096 || count <= 0)
+		return -EMSGSIZE;
 	if ( copy_from_user( &x, depth->x, sizeof(x) ) ) {
 		return -EFAULT;
 	}
@@ -1048,6 +1051,9 @@
 
 	count = depth->n;
 
+	if (count > 4096 || count <= 0)
+		return -EMSGSIZE;
+
 	x = kmalloc( count * sizeof(*x), 0 );
 	if ( x == NULL ) {
 		return -ENOMEM;
@@ -1178,6 +1184,10 @@
 	}
 
 	count = depth->n;
+	
+	if (count > 4096 || count <= 0)
+		return -EMSGSIZE;
+
 	if ( copy_from_user( &x, depth->x, sizeof(x) ) ) {
 		return -EFAULT;
 	}
@@ -1235,6 +1245,8 @@
 	}
 
 	count = depth->n;
+	if (count > 4096 || count <= 0)
+		return -EMSGSIZE;
 	if ( count > dev_priv->depth_pitch ) {
 		count = dev_priv->depth_pitch;
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)