All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 1/3] libdrm: Plug memory leaks
@ 2011-12-20 18:26 ville.syrjala
  2011-12-20 18:26 ` [PATCH libdrm 2/3] libdrm: Add drmModeFreePlaneResources() ville.syrjala
  2011-12-20 18:26 ` [PATCH libdrm 3/3] libdrm: Fix AddFB2 memcpy() size ville.syrjala
  0 siblings, 2 replies; 3+ messages in thread
From: ville.syrjala @ 2011-12-20 18:26 UTC (permalink / raw)
  To: dri-devel

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

drmModeFreeResources() always leaked some memory.
drmModeGetPlaneResources() and drmModeGetPlane() leaked in one error
path.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 xf86drmMode.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index da7b462..e67ed4a 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -96,6 +96,10 @@ void drmModeFreeResources(drmModeResPtr ptr)
 	if (!ptr)
 		return;
 
+	drmFree(ptr->fbs);
+	drmFree(ptr->crtcs);
+	drmFree(ptr->connectors);
+	drmFree(ptr->encoders);
 	drmFree(ptr);
 
 }
@@ -898,6 +902,7 @@ retry:
 				 ovr.count_format_types, sizeof(uint32_t));
 	if (ovr.count_format_types && !r->formats) {
 		drmFree(r->formats);
+		drmFree(r);
 		r = 0;
 	}
 
@@ -951,6 +956,7 @@ retry:
 				  res.count_planes, sizeof(uint32_t));
 	if (res.count_planes && !r->planes) {
 		drmFree(r->planes);
+		drmFree(r);
 		r = 0;
 	}
 
-- 
1.7.3.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH libdrm 2/3] libdrm: Add drmModeFreePlaneResources()
  2011-12-20 18:26 [PATCH libdrm 1/3] libdrm: Plug memory leaks ville.syrjala
@ 2011-12-20 18:26 ` ville.syrjala
  2011-12-20 18:26 ` [PATCH libdrm 3/3] libdrm: Fix AddFB2 memcpy() size ville.syrjala
  1 sibling, 0 replies; 3+ messages in thread
From: ville.syrjala @ 2011-12-20 18:26 UTC (permalink / raw)
  To: dri-devel

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

This function was missing.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 xf86drmMode.c |    9 +++++++++
 xf86drmMode.h |    1 +
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index e67ed4a..473e734 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -965,3 +965,12 @@ err_allocs:
 
 	return r;
 }
+
+void drmModeFreePlaneResources(drmModePlaneResPtr ptr)
+{
+	if (!ptr)
+		return;
+
+	drmFree(ptr->planes);
+	drmFree(ptr);
+}
diff --git a/xf86drmMode.h b/xf86drmMode.h
index c0fc2ef..34f5fb1 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -305,6 +305,7 @@ extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
 extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
 extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
 extern void drmModeFreePlane( drmModePlanePtr ptr );
+extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr);
 
 /**
  * Retrives all of the resources associated with a card.
-- 
1.7.3.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH libdrm 3/3] libdrm: Fix AddFB2 memcpy() size
  2011-12-20 18:26 [PATCH libdrm 1/3] libdrm: Plug memory leaks ville.syrjala
  2011-12-20 18:26 ` [PATCH libdrm 2/3] libdrm: Add drmModeFreePlaneResources() ville.syrjala
@ 2011-12-20 18:26 ` ville.syrjala
  1 sibling, 0 replies; 3+ messages in thread
From: ville.syrjala @ 2011-12-20 18:26 UTC (permalink / raw)
  To: dri-devel

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Using sizeof() on a function parameter with an array type does not
work. sizeof() treats such parameters as pointers.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 xf86drmMode.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index 473e734..c809c44 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -271,9 +271,9 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
 	f.height = height;
 	f.pixel_format = pixel_format;
 	f.flags = flags;
-	memcpy(f.handles, bo_handles, sizeof(bo_handles));
-	memcpy(f.pitches, pitches, sizeof(pitches));
-	memcpy(f.offsets, offsets, sizeof(offsets));
+	memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0]));
+	memcpy(f.pitches, pitches, 4 * sizeof(pitches[0]));
+	memcpy(f.offsets, offsets, 4 * sizeof(offsets[0]));
 
 	if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f)))
 		return ret;
-- 
1.7.3.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-20 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20 18:26 [PATCH libdrm 1/3] libdrm: Plug memory leaks ville.syrjala
2011-12-20 18:26 ` [PATCH libdrm 2/3] libdrm: Add drmModeFreePlaneResources() ville.syrjala
2011-12-20 18:26 ` [PATCH libdrm 3/3] libdrm: Fix AddFB2 memcpy() size ville.syrjala

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.