Skip to contentSkip to conversation

locks: missing unlock on error in generic_add_lease()

PATCH Superseded Dan Carpenter 2 participants 4 messages Nov 13, 2013

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

PATCH 1/1 locks: missing unlock on error in generic_add_lease()

We should unlock here before returning.

Fixes df4e8d2c1d2b ('locks: implement delegations')

---
Static checker stuff.

fs/locks.c +1 -0
index f99d52b..92a0f0a 100644
@@ -1494,6 +1494,7 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp
 
 	if (is_deleg && arg = F_WRLCK) {
 		/* Write delegations are not currently supported: */
+		mutex_unlock(&inode->i_mutex);
 		WARN_ON_ONCE(1);
 		return -EINVAL;
 	}
Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Dan Carpenter

We should unlock here before returning.

A buggy-caller case, so shouldn't be a huge deal, but obviously should be fixed, thanks!

I'm assuming Al will pick it up.

(Though error = -EAGAIN and "goto out" would be more consistent with other exits.)

--b.

Quoted 18 lines
Fixes df4e8d2c1d2b ('locks: implement delegations')

---
Static checker stuff.

fs/locks.c +1 -0
index f99d52b..92a0f0a 100644
@@ -1494,6 +1494,7 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp
 
 	if (is_deleg && arg = F_WRLCK) {
 		/* Write delegations are not currently supported: */
+		mutex_unlock(&inode->i_mutex);
 		WARN_ON_ONCE(1);
 		return -EINVAL;
 	}
#2 lore raw
Quoted 6 lines · J. Bruce Fields
Quoted 1 line · Dan Carpenter

We should unlock here before returning.

A buggy-caller case, so shouldn't be a huge deal, but obviously should be fixed, thanks!

Quoted 6 lines

I'm assuming Al will pick it up.

(Though error = -EAGAIN and "goto out" would be more consistent with other exits.)

-EINVAL, but yeah you're right. I'll resend.

regards,
dan carpenter

#3 lore raw

PATCH v2 1/1 locks: missing unlock on error in generic_add_lease()

In reply to J. Bruce Fields

We should unlock here before returning.

Fixes df4e8d2c1d2b ('locks: implement delegations')

---
v2: Style fix

fs/locks.c +2 -1
index f99d52b..7b7ed7d 100644
@@ -1495,7 +1495,8 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp
 	if (is_deleg && arg = F_WRLCK) {
 		/* Write delegations are not currently supported: */
 		WARN_ON_ONCE(1);
-		return -EINVAL;
+		error = -EINVAL;
+		goto out;
 	}
 
 	error = -EAGAIN;