mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/auth: Only drm_drop_master if it exists
@ 2026-04-16 21:00 Jonathan Cavitt
  2026-04-17  4:14 ` Luben Tuikov
  2026-04-22 19:13 ` Dmitry Baryshkov
  0 siblings, 2 replies; 4+ messages in thread
From: Jonathan Cavitt @ 2026-04-16 21:00 UTC (permalink / raw)
  To: dri-devel
  Cc: saurabhg.gupta, alex.zuo, jonathan.cavitt, linux-kernel,
	maarten.lankhorst, mripard, tzimmerman, airlied, simona

It is possible that both dev->master and file_priv->master are NULL when
passed to drm_master_release, which would result in dev being passed to
drm_drop_master (as NULL == NULL here).  This would result in a NULL
pointer dereference when passing dev->master to drm_master_put in
drm_drop_master.

Only call drm_drop_master if dev->master exists.  Also, make sure the
original calling requirement is maintained (dev->master ==
file_priv->master).

This fixes a static analysis issue.

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
---
 drivers/gpu/drm/drm_auth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index e17bb0f1f9e0..e5013b870ba0 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -347,7 +347,7 @@ void drm_master_release(struct drm_file *file_priv)
 	if (!drm_is_current_master_locked(file_priv))
 		goto out;
 
-	if (dev->master == file_priv->master)
+	if (dev->master && dev->master == file_priv->master)
 		drm_drop_master(dev, file_priv);
 out:
 	if (drm_core_check_feature(dev, DRIVER_MODESET) && file_priv->is_master) {
-- 
2.53.0


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

end of thread, other threads:[~2026-04-22 19:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-16 21:00 [PATCH] drm/auth: Only drm_drop_master if it exists Jonathan Cavitt
2026-04-17  4:14 ` Luben Tuikov
2026-04-22 19:13 ` Dmitry Baryshkov
2026-04-22 19:51   ` Cavitt, Jonathan

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

Powered by JetHome