mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/atomic_helper: Add missing NULL check for drm_plane_helper_funcs.atomic_update
@ 2024-09-27 20:46 Lyude Paul
  2024-09-30  6:26 ` Thomas Zimmermann
  2024-09-30  7:01 ` Maxime Ripard
  0 siblings, 2 replies; 6+ messages in thread
From: Lyude Paul @ 2024-09-27 20:46 UTC (permalink / raw)
  To: dri-devel
  Cc: stable, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Sean Paul, open list

Something I discovered while writing rvkms since some versions of the
driver didn't have a filled out atomic_update function - we mention that
this callback is "optional", but we don't actually check whether it's NULL
or not before calling it. As a result, we'll segfault if it's not filled
in.

  rvkms rvkms.0: [drm:drm_atomic_helper_commit_modeset_disables] modeset on [ENCODER:36:Virtual-36]
  BUG: kernel NULL pointer dereference, address: 0000000000000000
  PGD 0 P4D 0
  Oops: Oops: 0010 [#1] PREEMPT SMP NOPTI
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-20240813-1.fc40 08/13/2024
  RIP: 0010:0x0

So, let's fix that.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Fixes: c2fcd274bce5 ("drm: Add atomic/plane helpers")
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v3.19+
---
 drivers/gpu/drm/drm_atomic_helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 43cdf39019a44..b3c507040c6d6 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2797,7 +2797,8 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 
 			funcs->atomic_disable(plane, old_state);
 		} else if (new_plane_state->crtc || disabling) {
-			funcs->atomic_update(plane, old_state);
+			if (funcs->atomic_update)
+				funcs->atomic_update(plane, old_state);
 
 			if (!disabling && funcs->atomic_enable) {
 				if (drm_atomic_plane_enabling(old_plane_state, new_plane_state))
@@ -2889,7 +2890,8 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)
 		if (disabling && plane_funcs->atomic_disable) {
 			plane_funcs->atomic_disable(plane, old_state);
 		} else if (new_plane_state->crtc || disabling) {
-			plane_funcs->atomic_update(plane, old_state);
+			if (plane_funcs->atomic_update)
+				plane_funcs->atomic_update(plane, old_state);
 
 			if (!disabling && plane_funcs->atomic_enable) {
 				if (drm_atomic_plane_enabling(old_plane_state, new_plane_state))

base-commit: 22512c3ee0f47faab5def71c4453638923c62522
-- 
2.46.1


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

end of thread, other threads:[~2024-10-21 13:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-27 20:46 [PATCH] drm/atomic_helper: Add missing NULL check for drm_plane_helper_funcs.atomic_update Lyude Paul
2024-09-30  6:26 ` Thomas Zimmermann
2024-09-30  7:01 ` Maxime Ripard
2024-09-30  7:06   ` Thomas Zimmermann
2024-09-30 19:45     ` Lyude Paul
2024-10-21 13:30       ` Maxime Ripard

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®