public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: vop: Don't crash for invalid duplicate_state()
@ 2022-06-18  0:26 Brian Norris
  2022-06-23 16:46 ` Sean Paul
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Brian Norris @ 2022-06-18  0:26 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Heiko Stübner
  Cc: dri-devel, linux-rockchip, linux-kernel, Sandy Huang,
	Doug Anderson, Sean Paul, Brian Norris

It's possible for users to try to duplicate the CRTC state even when the
state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other
users of __drm_atomic_helper_crtc_duplicate_state()) already guard this
with a WARN_ON() instead of crashing, so let's do that here too.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 74562d40f639..daf192881353 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1570,6 +1570,9 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc)
 {
 	struct rockchip_crtc_state *rockchip_state;
 
+	if (WARN_ON(!crtc->state))
+		return NULL;
+
 	rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL);
 	if (!rockchip_state)
 		return NULL;
-- 
2.36.1.476.g0c4daa206d-goog


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2022-07-03 11:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-18  0:26 [PATCH] drm/rockchip: vop: Don't crash for invalid duplicate_state() Brian Norris
2022-06-23 16:46 ` Sean Paul
2022-06-23 23:44 ` Doug Anderson
2022-06-24  7:23   ` Heiko Stuebner
2022-06-24 17:57     ` Brian Norris
2022-06-24 20:37       ` Heiko Stuebner
2022-07-03 11:11 ` Heiko Stuebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox