Skip to contentSkip to conversation

drm/aperture: Fix missing unlock on error in devm_aperture_acquire()

PATCH In review Zou Wei 2 participants 2 messages May 13, 2021

Subsystems (2)
lore
Share & tools
lore

Zou Wei

author
#0 lore raw

PATCH 1/1 drm/aperture: Fix missing unlock on error in devm_aperture_acquire()

Add the missing unlock before return from function devm_aperture_acquire() in the error handling case.

---
 drivers/gpu/drm/drm_aperture.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_aperture.c +6 -2
index 33bf018..9335d9d 100644
@@ -164,13 +164,17 @@ static int devm_aperture_acquire(struct drm_device *dev,
 
 	list_for_each(pos, &drm_apertures) {
 		ap = container_of(pos, struct drm_aperture, lh);
-		if (overlap(base, end, ap->base, ap->base + ap->size))
+		if (overlap(base, end, ap->base, ap->base + ap->size)) {
+			mutex_unlock(&drm_apertures_lock);
 			return -EBUSY;
+		}
 	}
 
 	ap = devm_kzalloc(dev->dev, sizeof(*ap), GFP_KERNEL);
-	if (!ap)
+	if (!ap) {
+		mutex_unlock(&drm_apertures_lock);
 		return -ENOMEM;
+	}
 
 	ap->dev = dev;
 	ap->base = base;
Signature · 1 line
2.6.2
#1 lore raw

Hi

Am 13.05.21 um 10:46 schrieb Zou Wei:

Quoted 5 lines

Add the missing unlock before return from function devm_aperture_acquire() in the error handling case.

I added a Fixes tag and queued up the patch for drm-misc-next. Thanks!

Best regards
Thomas

Quoted 29 lines
---
  drivers/gpu/drm/drm_aperture.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_aperture.c +6 -2
index 33bf018..9335d9d 100644
@@ -164,13 +164,17 @@ static int devm_aperture_acquire(struct drm_device *dev,
 
  	list_for_each(pos, &drm_apertures) {
  		ap = container_of(pos, struct drm_aperture, lh);
-		if (overlap(base, end, ap->base, ap->base + ap->size))
+		if (overlap(base, end, ap->base, ap->base + ap->size)) {
+			mutex_unlock(&drm_apertures_lock);
  			return -EBUSY;
+		}
  	}
 
  	ap = devm_kzalloc(dev->dev, sizeof(*ap), GFP_KERNEL);
-	if (!ap)
+	if (!ap) {
+		mutex_unlock(&drm_apertures_lock);
  		return -ENOMEM;
+	}
 
  	ap->dev = dev;
  	ap->base = base;
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer