Okay Keith,

here's a patch set for adding the extra size arg to DRM_FREE.

(attached)

It applies from the top of the 'os-support' directory.

I generated it with "cvs diff -u". I believe GNU patch will ignore the
extra cvs type stuff, but if not, lemme know.


? bsd/Makefile
? bsd/drm/Makefile
? bsd/drm/kernel/Makefile
Index: bsd/drm/kernel/drm_dma.h
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm_dma.h,v
retrieving revision 1.11
diff -u -r1.11 drm_dma.h
--- bsd/drm/kernel/drm_dma.h    21 Feb 2003 23:23:03 -0000      1.11
+++ bsd/drm/kernel/drm_dma.h    2 Mar 2003 23:46:36 -0000
@@ -692,7 +692,7 @@
                                psignal(p, vbl_sig->signo);
 
                        TAILQ_REMOVE(&dev->vbl_sig_list, vbl_sig, link);
-                       DRM_FREE(vbl_sig);
+                       DRM_FREE(vbl_sig,sizeof(*vbl_sig));
                }
                vbl_sig = next;
        }
Index: bsd/drm/kernel/drm_os_freebsd.h
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm_os_freebsd.h,v
retrieving revision 1.12
diff -u -r1.12 drm_os_freebsd.h
--- bsd/drm/kernel/drm_os_freebsd.h     21 Feb 2003 23:23:04 -0000      1.12
+++ bsd/drm/kernel/drm_os_freebsd.h     2 Mar 2003 23:46:36 -0000
@@ -102,7 +102,7 @@
 #define DRM_IRQ_ARGS           void *arg
 #define DRM_DEVICE             drm_device_t    *dev    = kdev->si_drv1
 #define DRM_MALLOC(size)       malloc( size, DRM(M_DRM), M_NOWAIT )
-#define DRM_FREE(pt)           free( pt, DRM(M_DRM) )
+#define DRM_FREE(pt,size)              free( pt, DRM(M_DRM) )
 #define DRM_VTOPHYS(addr)      vtophys(addr)
 
 /* Read/write from bus space, with byteswapping to le if necessary */
Index: bsd/drm/kernel/drm_os_netbsd.h
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm_os_netbsd.h,v
retrieving revision 1.3
diff -u -r1.3 drm_os_netbsd.h
--- bsd/drm/kernel/drm_os_netbsd.h      21 Feb 2003 23:23:04 -0000      1.3
+++ bsd/drm/kernel/drm_os_netbsd.h      2 Mar 2003 23:46:36 -0000
@@ -89,7 +89,7 @@
 extern const int DRM(M_DRM) = M_DEVBUF;
 #endif /* __NetBSD_Version__ */
 #define DRM_MALLOC(size)       malloc( size, DRM(M_DRM), M_NOWAIT )
-#define DRM_FREE(pt)           free( pt, DRM(M_DRM) )
+#define DRM_FREE(pt,size)              free( pt, DRM(M_DRM) )
 #define DRM_VTOPHYS(addr)      vtophys(addr)
 
 #define DRM_READ8(map, offset)         bus_space_read_1(  (map)->iot, (map)->ioh, 
(offset) )
Index: linux/drm/kernel/drm_dma.h
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_dma.h,v
retrieving revision 1.12
diff -u -r1.12 drm_dma.h
--- linux/drm/kernel/drm_dma.h  2 Feb 2003 03:06:46 -0000       1.12
+++ linux/drm/kernel/drm_dma.h  2 Mar 2003 23:46:36 -0000
@@ -714,7 +714,7 @@
 
                        list_del( (struct list_head *) vbl_sig );
 
-                       DRM_FREE( vbl_sig );
+                       DRM_FREE(vbl_sig,sizeof(*vbl_sig));
 
                        dev->vbl_pending--;
                }
Index: linux/drm/kernel/drm_os_linux.h
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_os_linux.h,v
retrieving revision 1.6
diff -u -r1.6 drm_os_linux.h
--- linux/drm/kernel/drm_os_linux.h     21 Feb 2003 23:23:07 -0000      1.6
+++ linux/drm/kernel/drm_os_linux.h     2 Mar 2003 23:46:36 -0000
@@ -42,7 +42,7 @@
 
 /* malloc/free without the overhead of DRM(alloc) */
 #define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
-#define DRM_FREE(x) kfree(x)
+#define DRM_FREE(x,size) kfree(x)
 
 #define DRM_GETSAREA()                                                  \
 do {                                                                    \
Index: shared/drm/kernel/r128_state.c
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_state.c,v
retrieving revision 1.4
diff -u -r1.4 r128_state.c
--- shared/drm/kernel/r128_state.c      30 Oct 2002 06:10:34 -0000      1.4
+++ shared/drm/kernel/r128_state.c      2 Mar 2003 23:46:37 -0000
@@ -896,7 +896,7 @@
        int count, x, y;
        u32 *buffer;
        u8 *mask;
-       int i;
+       int i, buffer_size, mask_size;
        RING_LOCALS;
        DRM_DEBUG( "\n" );
 
@@ -908,25 +908,25 @@
                return DRM_ERR(EFAULT);
        }
 
-       buffer = DRM_MALLOC( depth->n * sizeof(u32) );
+       buffer_size = depth->n * sizeof(u32);
+       buffer = DRM_MALLOC( buffer_size );
        if ( buffer == NULL )
                return DRM_ERR(ENOMEM);
-       if ( DRM_COPY_FROM_USER( buffer, depth->buffer,
-                            depth->n * sizeof(u32) ) ) {
-               DRM_FREE( buffer );
+       if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
+               DRM_FREE( buffer, buffer_size);
                return DRM_ERR(EFAULT);
        }
 
+       mask_size = depth->n * sizeof(u8);
        if ( depth->mask ) {
-               mask = DRM_MALLOC( depth->n * sizeof(u8) );
+               mask = DRM_MALLOC( mask_size );
                if ( mask == NULL ) {
-                       DRM_FREE( buffer );
+                       DRM_FREE( buffer, buffer_size );
                        return DRM_ERR(ENOMEM);
                }
-               if ( DRM_COPY_FROM_USER( mask, depth->mask,
-                                    depth->n * sizeof(u8) ) ) {
-                       DRM_FREE( buffer );
-                       DRM_FREE( mask );
+               if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
+                       DRM_FREE( buffer, buffer_size );
+                       DRM_FREE( mask, mask_size );
                        return DRM_ERR(EFAULT);
                }
 
@@ -953,7 +953,7 @@
                        }
                }
 
-               DRM_FREE( mask );
+               DRM_FREE( mask, mask_size );
        } else {
                for ( i = 0 ; i < count ; i++, x++ ) {
                        BEGIN_RING( 6 );
@@ -977,7 +977,7 @@
                }
        }
 
-       DRM_FREE( buffer );
+       DRM_FREE( buffer, buffer_size );
 
        return 0;
 }
@@ -989,60 +989,62 @@
        int count, *x, *y;
        u32 *buffer;
        u8 *mask;
-       int i;
+       int i, xbuf_size, ybuf_size, buffer_size, mask_size;
        RING_LOCALS;
        DRM_DEBUG( "\n" );
 
        count = depth->n;
 
-       x = DRM_MALLOC( count * sizeof(*x) );
+       xbuf_size = count * sizeof(*x);
+       ybuf_size = count * sizeof(*y);
+       x = DRM_MALLOC( xbuf_size );
        if ( x == NULL ) {
                return DRM_ERR(ENOMEM);
        }
-       y = DRM_MALLOC( count * sizeof(*y) );
+       y = DRM_MALLOC( ybuf_size );
        if ( y == NULL ) {
-               DRM_FREE( x );
+               DRM_FREE( x, xbuf_size );
                return DRM_ERR(ENOMEM);
        }
-       if ( DRM_COPY_FROM_USER( x, depth->x, count * sizeof(int) ) ) {
-               DRM_FREE( x );
-               DRM_FREE( y );
+       if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
+               DRM_FREE( x, xbuf_size );
+               DRM_FREE( y, ybuf_size );
                return DRM_ERR(EFAULT);
        }
-       if ( DRM_COPY_FROM_USER( y, depth->y, count * sizeof(int) ) ) {
-               DRM_FREE( x );
-               DRM_FREE( y );
+       if ( DRM_COPY_FROM_USER( y, depth->y, xbuf_size ) ) {
+               DRM_FREE( x, xbuf_size );
+               DRM_FREE( y, ybuf_size );
                return DRM_ERR(EFAULT);
        }
 
-       buffer = DRM_MALLOC( depth->n * sizeof(u32) );
+       buffer_size = depth->n * sizeof(u32);
+       buffer = DRM_MALLOC( buffer_size );
        if ( buffer == NULL ) {
-               DRM_FREE( x );
-               DRM_FREE( y );
+               DRM_FREE( x, xbuf_size );
+               DRM_FREE( y, ybuf_size );
                return DRM_ERR(ENOMEM);
        }
-       if ( DRM_COPY_FROM_USER( buffer, depth->buffer,
-                            depth->n * sizeof(u32) ) ) {
-               DRM_FREE( x );
-               DRM_FREE( y );
-               DRM_FREE( buffer );
+       if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
+               DRM_FREE( x, xbuf_size );
+               DRM_FREE( y, ybuf_size );
+               DRM_FREE( buffer, buffer_size );
                return DRM_ERR(EFAULT);
        }
 
        if ( depth->mask ) {
-               mask = DRM_MALLOC( depth->n * sizeof(u8) );
+               mask_size = depth->n * sizeof(u8);
+               mask = DRM_MALLOC( mask_size );
                if ( mask == NULL ) {
-                       DRM_FREE( x );
-                       DRM_FREE( y );
-                       DRM_FREE( buffer );
+                       DRM_FREE( x, xbuf_size );
+                       DRM_FREE( y, ybuf_size );
+                       DRM_FREE( buffer, buffer_size );
                        return DRM_ERR(ENOMEM);
                }
-               if ( DRM_COPY_FROM_USER( mask, depth->mask,
-                                    depth->n * sizeof(u8) ) ) {
-                       DRM_FREE( x );
-                       DRM_FREE( y );
-                       DRM_FREE( buffer );
-                       DRM_FREE( mask );
+               if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
+                       DRM_FREE( x, xbuf_size );
+                       DRM_FREE( y, ybuf_size );
+                       DRM_FREE( buffer, buffer_size );
+                       DRM_FREE( mask, mask_size );
                        return DRM_ERR(EFAULT);
                }
 
@@ -1069,7 +1071,7 @@
                        }
                }
 
-               DRM_FREE( mask );
+               DRM_FREE( mask, mask_size );
        } else {
                for ( i = 0 ; i < count ; i++ ) {
                        BEGIN_RING( 6 );
@@ -1093,9 +1095,9 @@
                }
        }
 
-       DRM_FREE( x );
-       DRM_FREE( y );
-       DRM_FREE( buffer );
+       DRM_FREE( x, xbuf_size );
+       DRM_FREE( y, ybuf_size );
+       DRM_FREE( buffer, buffer_size );
 
        return 0;
 }
@@ -1146,7 +1148,7 @@
 {
        drm_r128_private_t *dev_priv = dev->dev_private;
        int count, *x, *y;
-       int i;
+       int i, xbuf_size, ybuf_size;
        RING_LOCALS;
        DRM_DEBUG( "%s\n", __FUNCTION__ );
 
@@ -1155,23 +1157,25 @@
                count = dev_priv->depth_pitch;
        }
 
-       x = DRM_MALLOC( count * sizeof(*x) );
+       xbuf_size = count * sizeof(*x);
+       ybuf_size = count * sizeof(*y);
+       x = DRM_MALLOC( xbuf_size );
        if ( x == NULL ) {
                return DRM_ERR(ENOMEM);
        }
-       y = DRM_MALLOC( count * sizeof(*y) );
+       y = DRM_MALLOC( ybuf_size );
        if ( y == NULL ) {
-               DRM_FREE( x );
+               DRM_FREE( x, xbuf_size );
                return DRM_ERR(ENOMEM);
        }
-       if ( DRM_COPY_FROM_USER( x, depth->x, count * sizeof(int) ) ) {
-               DRM_FREE( x );
-               DRM_FREE( y );
+       if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
+               DRM_FREE( x, xbuf_size );
+               DRM_FREE( y, ybuf_size );
                return DRM_ERR(EFAULT);
        }
-       if ( DRM_COPY_FROM_USER( y, depth->y, count * sizeof(int) ) ) {
-               DRM_FREE( x );
-               DRM_FREE( y );
+       if ( DRM_COPY_FROM_USER( y, depth->y, ybuf_size ) ) {
+               DRM_FREE( x, xbuf_size );
+               DRM_FREE( y, ybuf_size );
                return DRM_ERR(EFAULT);
        }
 
@@ -1199,8 +1203,8 @@
                ADVANCE_RING();
        }
 
-       DRM_FREE( x );
-       DRM_FREE( y );
+       DRM_FREE( x, xbuf_size );
+       DRM_FREE( y, ybuf_size );
 
        return 0;
 }
Index: shared/drm/kernel/radeon_mem.c
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_mem.c,v
retrieving revision 1.4
diff -u -r1.4 radeon_mem.c
--- shared/drm/kernel/radeon_mem.c      6 Jan 2003 07:38:25 -0000       1.4
+++ shared/drm/kernel/radeon_mem.c      2 Mar 2003 23:46:37 -0000
@@ -118,7 +118,7 @@
                p->size += q->size;
                p->next = q->next;
                p->next->prev = p;
-               DRM_FREE(q);
+               DRM_FREE(q, sizeof(*q));
        }
 
        if (p->prev->pid == 0) {
@@ -126,7 +126,7 @@
                q->size += p->size;
                q->next = p->next;
                q->next->prev = q;
-               DRM_FREE(p);
+               DRM_FREE(p, sizeof(*q));
        }
 }
 
@@ -141,7 +141,7 @@
        
        *heap = DRM_MALLOC(sizeof(**heap));
        if (!*heap) {
-               DRM_FREE( blocks );
+               DRM_FREE( blocks, sizeof(*blocks) );
                return -ENOMEM;
        }
 
@@ -181,7 +181,7 @@
                        p->size += q->size;
                        p->next = q->next;
                        p->next->prev = p;
-                       DRM_FREE(q);
+                       DRM_FREE(q, sizeof(*q));
                }
        }
 }
@@ -198,10 +198,10 @@
        for (p = (*heap)->next ; p != *heap ; ) {
                struct mem_block *q = p;
                p = p->next;
-               DRM_FREE(q);
+               DRM_FREE(q, sizeof(*q));
        }
 
-       DRM_FREE( *heap );
+       DRM_FREE( *heap, sizeof(**heap) );
        *heap = 0;
 }
 

Reply via email to