mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oarora Etimis <oaroraetimis@gmail.com>
To: Louis Chauvet <louis.chauvet@bootlin.com>,
	 Haneen Mohammed <hamohammed.sa@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,
	 Melissa Wen <melissa.srw@gmail.com>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>, Alex Hung <alex.hung@amd.com>,
	 Robert Mader <robert.mader@collabora.com>,
	 Harry Wentland <harry.wentland@amd.com>,
	Simon Ser <contact@emersion.fr>,
	 Daniel Stone <daniels@collabora.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/7] drm/vkms: free the colorop whose initialization failed
Date: Sat, 28 Nov 2026 19:19:40 +0100	[thread overview]
Message-ID: <20261128-colorop-v2-2-6e76c66cf1eb@gmail.com> (raw)
In-Reply-To: <20261128-colorop-v2-0-6e76c66cf1eb@gmail.com>

The error path of vkms_initialize_color_pipeline() walks ops[0..i-1],
but ops[i] is already allocated when its drm_plane_colorop_*_init()
call fails, so it leaks.

Walk ops[0..i] instead, and call drm_colorop_cleanup() only on the
entries that were linked, since init can fail before that.

Fixes: c1e578bd08da ("drm/vkms: Add enumerated 1D curve colorop")

Signed-off-by: Oarora Etimis <oaroraetimis@gmail.com>
---
 drivers/gpu/drm/vkms/vkms_colorop.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c
index 9424b1994239..4e6a82193f2e 100644
--- a/drivers/gpu/drm/vkms/vkms_colorop.c
+++ b/drivers/gpu/drm/vkms/vkms_colorop.c
@@ -126,11 +126,17 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
 	return 0;
 
 cleanup:
-	for (j = 0; j < i; j++) {
-		if (ops[j]) {
+	for (j = 0; j <= i && j < ARRAY_SIZE(ops); j++) {
+		if (!ops[j])
+			continue;
+
+		/*
+		 * drm_plane_colorop_init() can fail before the colorop is
+		 * linked and has a device; there is nothing to undo then.
+		 */
+		if (ops[j]->dev)
 			drm_colorop_cleanup(ops[j]);
-			kfree(ops[j]);
-		}
+		kfree(ops[j]);
 	}
 
 	return ret;

-- 
2.56.1


  parent reply	other threads:[~2026-11-28 18:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 18:19 [PATCH v2 0/7] drm/vkms: complete the plane color pipeline Oarora Etimis
2026-11-28 18:19 ` [PATCH v2 1/7] drm/vkms: add the colorops of a plane that is being enabled Oarora Etimis
2026-11-28 18:19 ` Oarora Etimis [this message]
2026-11-28 18:19 ` [PATCH v2 3/7] drm/vkms: use the colorop states of the state being composed Oarora Etimis
2026-11-28 18:19 ` [PATCH v2 4/7] drm/vkms: add a programmable 1D LUT colorop Oarora Etimis
2026-11-28 18:19 ` [PATCH v2 5/7] drm/vkms: add a 3D " Oarora Etimis
2026-11-28 18:19 ` [PATCH v2 6/7] drm/vkms: add a multiplier colorop Oarora Etimis
2026-11-28 18:19 ` [PATCH v2 7/7] drm/vkms: add KUnit coverage for the 3D LUT and multiplier colorops Oarora Etimis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128-colorop-v2-2-6e76c66cf1eb@gmail.com \
    --to=oaroraetimis@gmail.com \
    --cc=airlied@gmail.com \
    --cc=alex.hung@amd.com \
    --cc=contact@emersion.fr \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=harry.wentland@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=melissa.srw@gmail.com \
    --cc=mripard@kernel.org \
    --cc=robert.mader@collabora.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®