[PATCH 11/62] drm/pagemap: Unlock cache->lock before freeing it

Bart Van Assche posted 62 patches 1 month ago
Only 30 patches received!
[PATCH 11/62] drm/pagemap: Unlock cache->lock before freeing it
Posted by Bart Van Assche 1 month ago
From: Bart Van Assche <bvanassche@acm.org>

Although freeing a spinlock without unlocking it is fine, this confuses
static analyzers. Hence this patch.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/gpu/drm/drm_pagemap_util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_pagemap_util.c b/drivers/gpu/drm/drm_pagemap_util.c
index 14ddb948a32e..50cb5f9cdac5 100644
--- a/drivers/gpu/drm/drm_pagemap_util.c
+++ b/drivers/gpu/drm/drm_pagemap_util.c
@@ -74,6 +74,8 @@ static void drm_pagemap_cache_fini(void *arg)
 		cache->dpagemap = NULL;
 		spin_unlock(&cache->lock);
 		drm_pagemap_destroy(dpagemap, false);
+	} else {
+		spin_unlock(&cache->lock);
 	}
 
 out:
Re: [PATCH 11/62] drm/pagemap: Unlock cache->lock before freeing it
Posted by Matthew Brost 1 month ago
On Mon, Feb 23, 2026 at 02:00:11PM -0800, Bart Van Assche wrote:
> From: Bart Van Assche <bvanassche@acm.org>
> 
> Although freeing a spinlock without unlocking it is fine, this confuses

Fine, but pretty bad practice.

> static analyzers. Hence this patch.
> 
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>

With that:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>

We can apply this to the DRM branches and propagate this up to Linus
during 7.0 cycle if that works for you? Or if you have other plans to
merge, let us know.

Matt

> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/gpu/drm/drm_pagemap_util.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_pagemap_util.c b/drivers/gpu/drm/drm_pagemap_util.c
> index 14ddb948a32e..50cb5f9cdac5 100644
> --- a/drivers/gpu/drm/drm_pagemap_util.c
> +++ b/drivers/gpu/drm/drm_pagemap_util.c
> @@ -74,6 +74,8 @@ static void drm_pagemap_cache_fini(void *arg)
>  		cache->dpagemap = NULL;
>  		spin_unlock(&cache->lock);
>  		drm_pagemap_destroy(dpagemap, false);
> +	} else {
> +		spin_unlock(&cache->lock);
>  	}
>  
>  out:
Re: [PATCH 11/62] drm/pagemap: Unlock cache->lock before freeing it
Posted by Bart Van Assche 1 month ago
On 2/23/26 2:14 PM, Matthew Brost wrote:
> On Mon, Feb 23, 2026 at 02:00:11PM -0800, Bart Van Assche wrote:
>> From: Bart Van Assche <bvanassche@acm.org>
>>
>> Although freeing a spinlock without unlocking it is fine, this confuses
> 
> Fine, but pretty bad practice.
> 
>> static analyzers. Hence this patch.
>>
>> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Cc: Maxime Ripard <mripard@kernel.org>
>> Cc: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>> Cc: Matthew Brost <matthew.brost@intel.com>
> 
> With that:
> Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> 
> We can apply this to the DRM branches and propagate this up to Linus
> during 7.0 cycle if that works for you? Or if you have other plans to
> merge, let us know.
Peter asked me to split this series into one series per maintainer and
to send the patches directly to the respective maintainers. Feel free to
queue this patch in a DRM branch.

Thanks,

Bart.
Re: [PATCH 11/62] drm/pagemap: Unlock cache->lock before freeing it
Posted by Matthew Brost 1 month ago
On Mon, Feb 23, 2026 at 02:20:20PM -0800, Bart Van Assche wrote:
> On 2/23/26 2:14 PM, Matthew Brost wrote:
> > On Mon, Feb 23, 2026 at 02:00:11PM -0800, Bart Van Assche wrote:
> > > From: Bart Van Assche <bvanassche@acm.org>
> > > 
> > > Although freeing a spinlock without unlocking it is fine, this confuses
> > 
> > Fine, but pretty bad practice.
> > 
> > > static analyzers. Hence this patch.
> > > 
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Cc: Maxime Ripard <mripard@kernel.org>
> > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > > Cc: Matthew Brost <matthew.brost@intel.com>
> > 
> > With that:
> > Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> > 
> > We can apply this to the DRM branches and propagate this up to Linus
> > during 7.0 cycle if that works for you? Or if you have other plans to
> > merge, let us know.
> Peter asked me to split this series into one series per maintainer and
> to send the patches directly to the respective maintainers. Feel free to
> queue this patch in a DRM branch.
> 

I've reposted the patch, retaining you as the author, to our lists [1],
since we pull patches from the lists when merging and to run our CI.

Let me know if anything looks wrong there, but I’ll merge once CI comes
back (might take a few days, as CI is currently broken after we rebased
on 7.0‑rc1). After that, it will be in the PR up to Linus during the
fixes phase.

Matt

[1] https://patchwork.freedesktop.org/series/162019/

> Thanks,
> 
> Bart.