Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 2008 18:06:34 +0000 (UTC)
From:      Robert Noland <rnoland@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r183834 - head/sys/dev/drm
Message-ID:  <200810131806.m9DI6Yvw082678@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rnoland
Date: Mon Oct 13 18:06:33 2008
New Revision: 183834
URL: http://svn.freebsd.org/changeset/base/183834

Log:
  Correct memory leak of info->rects.  Previously we would free info, but
  but abandon info->rects.
  
  Approved by:	jhb (mentor)

Modified:
  head/sys/dev/drm/drm_drawable.c

Modified: head/sys/dev/drm/drm_drawable.c
==============================================================================
--- head/sys/dev/drm/drm_drawable.c	Mon Oct 13 18:03:27 2008	(r183833)
+++ head/sys/dev/drm/drm_drawable.c	Mon Oct 13 18:06:33 2008	(r183834)
@@ -74,8 +74,8 @@ int drm_adddraw(struct drm_device *dev, 
 	struct drm_draw *draw = data;
 	struct bsd_drm_drawable_info *info;
 
-	info = drm_calloc(1, sizeof(struct bsd_drm_drawable_info),
-	    DRM_MEM_DRAWABLE);
+	info = malloc(sizeof(struct bsd_drm_drawable_info), DRM_MEM_DRAWABLE,
+	    M_NOWAIT | M_ZERO);
 	if (info == NULL)
 		return ENOMEM;
 
@@ -102,8 +102,8 @@ int drm_rmdraw(struct drm_device *dev, v
 		    (struct bsd_drm_drawable_info *)info);
 		DRM_SPINUNLOCK(&dev->drw_lock);
 		free_unr(dev->drw_unrhdr, draw->handle);
-		drm_free(info, sizeof(struct bsd_drm_drawable_info),
-		    DRM_MEM_DRAWABLE);
+		free(info->rects, DRM_MEM_DRAWABLE);
+		free(info, DRM_MEM_DRAWABLE);
 		return 0;
 	} else {
 		DRM_SPINUNLOCK(&dev->drw_lock);
@@ -126,9 +126,7 @@ int drm_update_draw(struct drm_device *d
 	case DRM_DRAWABLE_CLIPRECTS:
 		DRM_SPINLOCK(&dev->drw_lock);
 		if (update->num != info->num_rects) {
-			drm_free(info->rects,
-			    sizeof(*info->rects) * info->num_rects,
-			    DRM_MEM_DRAWABLE);
+			free(info->rects, DRM_MEM_DRAWABLE);
 			info->rects = NULL;
 			info->num_rects = 0;
 		}
@@ -137,8 +135,8 @@ int drm_update_draw(struct drm_device *d
 			return 0;
 		}
 		if (info->rects == NULL) {
-			info->rects = drm_alloc(sizeof(*info->rects) *
-			    update->num, DRM_MEM_DRAWABLE);
+			info->rects = malloc(sizeof(*info->rects) *
+			    update->num, DRM_MEM_DRAWABLE, M_NOWAIT);
 			if (info->rects == NULL) {
 				DRM_SPINUNLOCK(&dev->drw_lock);
 				return ENOMEM;
@@ -167,8 +165,8 @@ void drm_drawable_free_all(struct drm_de
 		    (struct bsd_drm_drawable_info *)info);
 		DRM_SPINUNLOCK(&dev->drw_lock);
 		free_unr(dev->drw_unrhdr, info->handle);
-		drm_free(info, sizeof(struct bsd_drm_drawable_info),
-		    DRM_MEM_DRAWABLE);
+		free(info->info.rects, DRM_MEM_DRAWABLE);
+		free(info, DRM_MEM_DRAWABLE);
 		DRM_SPINLOCK(&dev->drw_lock);
 	}
 	DRM_SPINUNLOCK(&dev->drw_lock);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810131806.m9DI6Yvw082678>