Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb5a18cf authored by Dan Carpenter's avatar Dan Carpenter Committed by John Stultz
Browse files

ptp: Fix some locking bugs in ptp_read()



In ptp_read there is an unlock missing on an error path, and a double
unlock on another error path.

Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Acked-by: default avatarRichard Cochran <richard.cochran@omicron.at>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent e23ef227
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -130,8 +130,10 @@ ssize_t ptp_read(struct posix_clock *pc,
		return -ERESTARTSYS;
	}

	if (ptp->defunct)
	if (ptp->defunct) {
		mutex_unlock(&ptp->tsevq_mux);
		return -ENODEV;
	}

	spin_lock_irqsave(&queue->lock, flags);

@@ -151,10 +153,8 @@ ssize_t ptp_read(struct posix_clock *pc,

	mutex_unlock(&ptp->tsevq_mux);

	if (copy_to_user(buf, event, cnt)) {
		mutex_unlock(&ptp->tsevq_mux);
	if (copy_to_user(buf, event, cnt))
		return -EFAULT;
	}

	return cnt;
}