* [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
* Re: [PATCH] drm/auth: Only drm_drop_master if it exists 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 1 sibling, 0 replies; 4+ messages in thread From: Luben Tuikov @ 2026-04-17 4:14 UTC (permalink / raw) To: Jonathan Cavitt, dri-devel Cc: saurabhg.gupta, alex.zuo, linux-kernel, maarten.lankhorst, mripard, tzimmerman, airlied, simona [-- Attachment #1.1.1: Type: text/plain, Size: 1614 bytes --] On 2026-04-16 17:00, Jonathan Cavitt wrote: > 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) { This is a good catch. Acked-by: Luben Tuikov <ltuikov89@gmail.com> -- Regards, Luben [-- Attachment #1.1.2: OpenPGP public key --] [-- Type: application/pgp-keys, Size: 677 bytes --] [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 236 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/auth: Only drm_drop_master if it exists 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 1 sibling, 1 reply; 4+ messages in thread From: Dmitry Baryshkov @ 2026-04-22 19:13 UTC (permalink / raw) To: Jonathan Cavitt Cc: dri-devel, saurabhg.gupta, alex.zuo, linux-kernel, maarten.lankhorst, mripard, tzimmerman, airlied, simona On Fri, Apr 17, 2026 at 05:00:47AM +0800, Jonathan Cavitt wrote: > 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) The previous call checks that file_priv->master != NULL. So, at this point the NULL == NULL check is not possible. I'm sorry, but this looks like a false positive. > + 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 > -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] drm/auth: Only drm_drop_master if it exists 2026-04-22 19:13 ` Dmitry Baryshkov @ 2026-04-22 19:51 ` Cavitt, Jonathan 0 siblings, 0 replies; 4+ messages in thread From: Cavitt, Jonathan @ 2026-04-22 19:51 UTC (permalink / raw) To: Dmitry Baryshkov Cc: dri-devel, Gupta, Saurabhg, Zuo, Alex, linux-kernel, Cavitt, Jonathan, maarten.lankhorst, mripard, tzimmerman, airlied, simona -----Original Message----- From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Sent: Wednesday, April 22, 2026 12:14 PM To: Cavitt, Jonathan <jonathan.cavitt@intel.com> Cc: dri-devel@lists.freedesktop.org; Gupta, Saurabhg <saurabhg.gupta@intel.com>; Zuo, Alex <alex.zuo@intel.com>; linux-kernel@vger.kernel.org; maarten.lankhorst@linux.intel.com; mripard@kernel.org; tzimmerman@suse.de; airlied@gmail.com; simona@ffwll.ch Subject: Re: [PATCH] drm/auth: Only drm_drop_master if it exists > > On Fri, Apr 17, 2026 at 05:00:47AM +0800, Jonathan Cavitt wrote: > > 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) > > The previous call checks that file_priv->master != NULL. So, at this > point the NULL == NULL check is not possible. You mean drm_is_current_master_locked? Internally, that performs the check "fpriv->is_master && drm_lease_owner(fpriv->master) == fpriv->minor->dev->master" It doesn't explicitly check for fpriv->master != NULL, but I don't think the current execution path allows for fpriv->is_master && !fpriv->master, so I'm guessing that's what you're referring to? Otherwise, we could be passing a NULL pointer to drm_lease_owner, which would itself be a NULL pointer dereference issue... > > I'm sorry, but this looks like a false positive. This has already been merged. If you think it necessary, please feel free to file a revert and send the request my way for review. -Jonathan Cavitt > > > + 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 > > > > -- > With best wishes > Dmitry > ^ 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