summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-04-14 18:42:23 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-04-14 20:45:26 +0100
commitae145c21e9fd3a12164f8b4720d059f9c158249e (patch)
treee56426423f54591416bbfd0c98941b58f6003f0e
parent69a7737abeded6ee923643bd8a80a5a84e6a979c (diff)
sna: Avoid leaking the plane resources when determining sprite planes
Fixes the tiny, one-off leak: ==1407== 8 bytes in 1 blocks are definitely lost in loss record 48 of 527 ==1407== at 0x402894D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1407== by 0x8580BE8: drmMalloc (xf86drm.c:147) ==1407== by 0x8583D54: drmAllocCpy (xf86drmMode.c:73) ==1407== by 0x8585265: drmModeGetPlaneResources (xf86drmMode.c:955) ==1407== by 0x8A1BCE9: sna_video_sprite_setup (sna_video_sprite.c:367) ==1407== by 0x8A1A0A3: sna_video_init (sna_video.c:523) ==1407== by 0x89FD4E0: sna_screen_init (sna_driver.c:935) ==1407== by 0x15AD80: AddScreen (dispatch.c:3909) ==1407== by 0x19A2DB: InitOutput (xf86Init.c:817) ==1407== by 0x14981C: main (main.c:204) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_video_sprite.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c
index 82db1224..0e5f3ab4 100644
--- a/src/sna/sna_video_sprite.c
+++ b/src/sna/sna_video_sprite.c
@@ -361,21 +361,21 @@ XF86VideoAdaptorPtr sna_video_sprite_setup(struct sna *sna,
ScreenPtr screen)
{
XF86VideoAdaptorPtr adaptor;
+ struct drm_mode_get_plane_res r;
struct sna_video *video;
- drmModePlaneRes *plane_resources;
- plane_resources = drmModeGetPlaneResources(sna->kgem.fd);
- if (!plane_resources)
+ memset(&r, 0, sizeof(struct drm_mode_get_plane_res));
+ if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETPLANERESOURCES, &r))
+ return NULL;
+ if (r.count_planes == 0)
return NULL;
adaptor = calloc(1,
sizeof(XF86VideoAdaptorRec) +
sizeof(struct sna_video) +
sizeof(DevUnion));
- if (!adaptor) {
- free(plane_resources);
+ if (!adaptor)
return NULL;
- }
adaptor->type = XvWindowMask | XvInputMask | XvImageMask;
adaptor->flags = VIDEO_OVERLAID_IMAGES /*| VIDEO_CLIP_TO_VIEWPORT */ ;
@@ -428,7 +428,5 @@ XF86VideoAdaptorPtr sna_video_sprite_setup(struct sna *sna,
xvColorKey = MAKE_ATOM("XV_COLORKEY");
- free(plane_resources);
-
return adaptor;
}