All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Fix memory leaks
@ 2019-08-19 19:40 ` Wenwen Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Wenwen Wang @ 2019-08-19 19:40 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Maarten Lankhorst, Maxime Ripard, Sean Paul, David Airlie,
	Daniel Vetter, open list:DRM DRIVERS, open list

In drm_universal_plane_init(), if 'format_count' is larger than 64, no
cleanup is executed, leading to memory/resource leaks. To fix this issue,
perform cleanup work before returning -EINVAL.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 drivers/gpu/drm/drm_plane.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index d6ad60a..2c0d0044 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -211,8 +211,11 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
 	 * First driver to need more than 64 formats needs to fix this. Each
 	 * format is encoded as a bit and the current code only supports a u64.
 	 */
-	if (WARN_ON(format_count > 64))
+	if (WARN_ON(format_count > 64)) {
+		kfree(plane->format_types);
+		drm_mode_object_unregister(dev, &plane->base);
 		return -EINVAL;
+	}
 
 	if (format_modifiers) {
 		const uint64_t *temp_modifiers = format_modifiers;
-- 
2.7.4


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

* [PATCH] drm: Fix memory leaks
@ 2019-08-19 19:40 ` Wenwen Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Wenwen Wang @ 2019-08-19 19:40 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Maarten Lankhorst, Maxime Ripard, Sean Paul, David Airlie,
	Daniel Vetter, open list:DRM DRIVERS, open list

In drm_universal_plane_init(), if 'format_count' is larger than 64, no
cleanup is executed, leading to memory/resource leaks. To fix this issue,
perform cleanup work before returning -EINVAL.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 drivers/gpu/drm/drm_plane.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index d6ad60a..2c0d0044 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -211,8 +211,11 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
 	 * First driver to need more than 64 formats needs to fix this. Each
 	 * format is encoded as a bit and the current code only supports a u64.
 	 */
-	if (WARN_ON(format_count > 64))
+	if (WARN_ON(format_count > 64)) {
+		kfree(plane->format_types);
+		drm_mode_object_unregister(dev, &plane->base);
 		return -EINVAL;
+	}
 
 	if (format_modifiers) {
 		const uint64_t *temp_modifiers = format_modifiers;
-- 
2.7.4

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

end of thread, other threads:[~2019-08-19 19:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 19:40 [PATCH] drm: Fix memory leaks Wenwen Wang
2019-08-19 19:40 ` Wenwen Wang

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.