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: Dan Carpenter <error27@gmail.com>
Acked-by: Richard Cochran <richard.cochran@omicron.at>
Signed-off-by: John Stultz <john.stultz@linaro.org>
This commit is contained in:
Dan Carpenter 2011-05-29 22:54:07 +03:00 committed by John Stultz
parent e23ef227d1
commit fb5a18cf7c

View File

@ -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;
}