summaryrefslogtreecommitdiffstats
path: root/sys/dev/drm
diff options
context:
space:
mode:
authorrnoland <rnoland@FreeBSD.org>2008-10-13 18:06:33 +0000
committerrnoland <rnoland@FreeBSD.org>2008-10-13 18:06:33 +0000
commit69ae2b2b5a37e65ff6b2e7d5e33a5fffd61a2eaf (patch)
tree2f18ec9905f55cd7087d6cd42f00ac206b7e8196 /sys/dev/drm
parent192b3600be5db1effa54d2e72717a7482aaeb52a (diff)
downloadFreeBSD-src-69ae2b2b5a37e65ff6b2e7d5e33a5fffd61a2eaf.zip
FreeBSD-src-69ae2b2b5a37e65ff6b2e7d5e33a5fffd61a2eaf.tar.gz
Correct memory leak of info->rects. Previously we would free info, but
but abandon info->rects. Approved by: jhb (mentor)
Diffstat (limited to 'sys/dev/drm')
-rw-r--r--sys/dev/drm/drm_drawable.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/sys/dev/drm/drm_drawable.c b/sys/dev/drm/drm_drawable.c
index b8e3d89..18f9976 100644
--- a/sys/dev/drm/drm_drawable.c
+++ b/sys/dev/drm/drm_drawable.c
@@ -74,8 +74,8 @@ int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
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, void *data, struct drm_file *file_priv)
(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 *dev, void *data,
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 *dev, void *data,
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_device *dev)
(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);
OpenPOWER on IntegriCloud