Skip to contentSkip to conversation

drm/via: reduce no need mutex_lock area

PATCH Applied Bernard Zhao 2 participants 2 messages Aug 14, 2020 – Oct 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/via: reduce no need mutex_lock area

In function via_mem_alloc`s error branch, DRM_ERROR is protected in the mutex_lock(&dev->struct_mutex) area.
From the code, we see that DRM_ERROR is just an error log print without any struct element, there is no need to protect this.

---
 drivers/gpu/drm/via/via_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/via/via_mm.c +1 -1
index 45cc9e900260..dae1bacd86c1 100644
@@ -129,9 +129,9 @@ int via_mem_alloc(struct drm_device *dev, void *data,
 	mutex_lock(&dev->struct_mutex);
 	if (0 == ((mem->type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized :
 		      dev_priv->agp_initialized)) {
+		mutex_unlock(&dev->struct_mutex);
 		DRM_ERROR
 		    ("Attempt to allocate from uninitialized memory manager.\n");
-		mutex_unlock(&dev->struct_mutex);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.26.2
Applied
#1 lore raw

Hi Bernard.

Quoted 6 lines · Bernard Zhao

In function via_mem_alloc`s error branch, DRM_ERROR is protected in the mutex_lock(&dev->struct_mutex) area.

Quoted 1 line

From the code, we see that DRM_ERROR is just an error log print

without any struct element, there is no need to protect this.

Thanks, applied to drm-misc-next.

The patch will show up in -next in a few weeks.

Sam