Skip to contentSkip to conversation

Lost unlock and fput in mqueue.c on error path

PATCH New Pavel Emelyanov 1 participant 1 message Nov 21, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Lost unlock and fput in mqueue.c on error path

The error path in sys_mq_getsetattr() after the call to audit_mq_getsetattr() is wrong - the info->lock is not unlocked and the struct file *filp is not put.

Fix them both.

---

ipc/mqueue.c +4 -2
index 0ce1ba6..7d1b8aa 100644
@@ -1144,8 +1144,10 @@ asmlinkage long sys_mq_getsetattr(mqd_t mqdes,
 	omqstat.mq_flags = filp->f_flags & O_NONBLOCK;
 	if (u_mqstat) {
 		ret = audit_mq_getsetattr(mqdes, &mqstat);
-		if (ret != 0)
-			goto out;
+		if (ret != 0) {
+			spin_unlock(&info->lock);
+			goto out_fput;
+		}
 		if (mqstat.mq_flags & O_NONBLOCK)
 			filp->f_flags |= O_NONBLOCK;
 		else