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

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

diff -urN linux-2.4.25/drivers/char/drm/r128_state.c linux-2.4.26/drivers/char/drm/r128_state.c
@@ -914,7 +914,7 @@
 
 	count = depth->n;
 	
-	if( count > 4096 )
+	if( count > 4096 || count <= 0)
 		return -EMSGSIZE;
 	if ( copy_from_user( &x, depth->x, sizeof(x) ) ) {
 		return -EFAULT;
@@ -1010,7 +1010,7 @@
 
 	count = depth->n;
 	
-	if( count > 4096 )
+	if( count > 4096 || count <= 0)
 		return -EMSGSIZE;
 
 	x = kmalloc( count * sizeof(*x), GFP_KERNEL );
@@ -1128,7 +1128,7 @@
 
 	count = depth->n;
 	
-	if ( count > 4096 )
+	if ( count > 4096 || count <= 0)
 		return -EMSGSIZE;
 	if ( copy_from_user( &x, depth->x, sizeof(x) ) ) {
 		return -EFAULT;
@@ -1172,6 +1172,9 @@
 	DRM_DEBUG( "%s\n", __FUNCTION__ );
 
 	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)